https://www.prisma.io/ logo
Join SlackCommunities
Powered by
# prisma-client
  • a

    Andrew Gold

    05/10/2020, 5:56 PM
    Hello! I am working on a project using Prisma and as we’ve gotten ready to deploy to production we’ve run into the issue noted here with pgBouncer. I would like to try out the fix you recommend here, but we are currently using Prisma 1. Is this fix implemented for Prisma 1 or do we need to upgrade to Prisma 2? Thanks so much!
  • m

    Martïn

    05/11/2020, 5:11 PM
    @Ryan @Ian Wensink @nikolasburk Any plans on developing subscription for Prisma Client? I came across Supabase’s real-time postgres implementation https://github.com/supabase/realtime, a tool that lets you listen to PostgreSQL database in realtime via websockets. This implementation could be helpful in implementing subscription for Prisma. This example uses the tool with NextJS for real-time updates: https://github.com/supabase/realtime/tree/master/examples/next-js/pages. In the coming days, I will be looking on how best to integrate this with my existing Postgres DB.
  • m

    Maurits

    05/16/2020, 1:40 PM
    Does somebody know of a workaround for this issue where I can’t invoke a
    deleteMany
    ?
  • c

    Corey Snyder

    05/19/2020, 2:06 AM
    It doesn’t seem like the Prisma generated client uses ES module system. Can someone confirm? I’m trying to move my whole app from “require” to “import” and I’m running into issues w/ the
    import {prisma} from './generated/prisma-client/index.js'
    or
    import prisma from './generated/prisma-client/index.js'
  • c

    Corey Snyder

    06/06/2020, 6:53 PM
    https://prisma.slack.com/archives/CA491RJH0/p1591469625353000
  • c

    Corey Snyder

    06/07/2020, 3:18 AM
    When connecting to the prisma graphQL interface directly, can you do where clauses? I was hoping to do something simple like:
    Copy code
    {
      human(id: "1000") {
        name
        height
      }
    }
    but when I typed
    id
    it kept trying to autocomplete it to
    where
    and nothing I tried would really work.
  • l

    Lucas Munhoz

    06/11/2020, 6:08 AM
    Is it possible to get only the query as a string instead of sending the query to the engine? For example if I do
    prisma.user.findOne({...})
    I would like to get the query statement only and don't make the call. I know is possible to enable logs in the prisma client, but I am looking for something more specific where I can access the query builder result instead. Something like
    prisma.user.findOne({...}).getRawQuery().
    That would not make any call to the db but just get the query statement from the engine. Would be awesome! Any directions on how I can accomplish this? Thank you!
    j
    j
    • 3
    • 10
  • g

    Gabriel Benson

    06/14/2020, 10:14 PM
    Is there a way to send a relational query that returns the scalar fields from each type?
    Copy code
    prisma.user({ id }).boxes({ where: { number: boxNumber } }).slots({ where: { number: slotNumber } });
  • l

    lkbr

    06/18/2020, 3:40 PM
    👋 Hi friends, is anyone using a combination of Prisma in Next.js
    getServerSideProps()
    +
    PromiseReturnType<typeof fn>
    (where
    fn
    is the function that returns prisma data)? Basically, defining
    type X = PromiseReturnType<typeof fn>
    seems to break Nexts automatic client side bundling elimination and includes
    fn
    (which contains prisma) client side. Which then means you get the
    Module not found: Can't resolve 'child_process' in...
    error. Am I doing something wrong is that specific combination not going to work?
    • 1
    • 1
  • t

    Thomas

    06/26/2020, 2:38 PM
    Hi all, I've been regularly having a local error for some time now.
    Copy code
    Error:
    Invalid `prisma.project.findMany()` invocation in
    webpack-internal:///./packages/prisma/repository/Project.ts:41:84
    
      Unknown error in Prisma Client
    
    This is a non-recoverable error which probably happens when the Prisma Query Engine has a panic.
    I don't get it because the query only works every other time. How if the server was overloaded or something... I use NextJS and Prisma (both are up to date in terms of versions) with Postgres in database Do you have a lead or an idea ? Do we need to set up a pgBouncer?
    j
    r
    • 3
    • 30
  • c

    Corey Snyder

    07/10/2020, 3:50 PM
    I just ran into an interesting problem. I have a schema which resembles this:
    Copy code
    type Frame{
      id: ID! @id
      primaryBoardSize: HolePattern
      supportedBoardSizes: [HolePattern] @scalarList(strategy: RELATION)
    }
    And I just noticed that I have no search methods for
    supportedBoardSizes
    in the generated client
    FrameWhereInput
    . Where as for
    primaryBoardSize
    I am offered the method
    primaryBoardSize_in, primaryBoardSize_not_in, primaryBoardSize, primaryBoardSize_not
    to search on. Does anyone know a workaround for this. I’d really like to be able to offer an ability to query where
    Frame.supportedBoardSizes
    includes [insert board size here]
    j
    • 2
    • 1
  • o

    Omar Harras

    08/02/2020, 4:49 PM
    Hello everyone, I just migrated to prisma 2, and I can’t run any query or mutation, each time I got
    Invalid prisma invocation
    Here is an example with a simple mutation :
    Copy code
    async createItem(parent, args, context) {
        const item = await context.prisma.item.create(
          {
            data: { ...args },
          },
        );
        return item;
      },
    // Got this error
    "message": "\nInvalid `prisma.item.create()` invocation
    ✔️ 1
    j
    • 2
    • 2
  • p

    Pieter

    08/07/2020, 12:56 PM
    @tim2 Thanks for demonstrating how prisma handles the N+1 problem. It will be pretty useful to get some buy-in from my peers to switch to prisma. I'd like to do a little demo to them using our codebase to demonstrate the improvement. How did you get it to log your queries out? We currently using sequelize, which works on a environment variable. Does prisma have something similar?
    ✔️ 1
    r
    • 2
    • 5
  • t

    Thomas

    08/19/2020, 1:51 PM
    Hello, I could use some help adding data on a many to many relationship. Here's my schema :
    Copy code
    model ProjectPro {
        id                 Int               @default(autoincrement()) @id
        name               String
        slug               String            @unique
        type               TypeProjectPro    @default(PLUGIN)
        settings_users_pro SettingsUserPro[] @relation(references: [id])
        created_at         DateTime?         @default(now())
        updated_at         DateTime?         @updatedAt
        deleted_at         DateTime?
    }
    
    model SettingsUserPro {
        id             Int          @default(autoincrement()) @id
        userId         Int
        type           String?      @default("month")
        User           User         @relation(fields: [userId], references: [id])
        projects_pro   ProjectPro[] @relation(references: [id])
        created_at     DateTime?    @default(now())
        updated_at     DateTime?    @updatedAt
        deleted_at     DateTime?
    }
    I'd like to associate a "project pro" with a "settings user pro"
  • t

    Thomas

    08/19/2020, 1:51 PM
    Copy code
    await prisma.settingsUserPro.update({
            data: {
                projects_pro: {
                    set: {
                        id: Number(projectProId),
                    },
                },
            },
            where: {
                id: Number(userId),
            },
        });
  • t

    Thomas

    08/19/2020, 1:52 PM
    And i have this error :
    AssertionError("[Query Graph] Expected a valid parent ID to be present for a nested set (disconnect part) on a many-to-many relation.
  • t

    Thomas

    08/19/2020, 1:52 PM
    an idea ?
  • t

    Thomas

    08/19/2020, 2:12 PM
    Okay found it, it was my user ID that wasn't a good match. 😅
  • g

    Greg Egan

    08/20/2020, 9:51 PM
    Copy code
    model BrandCategory {
      id     String  @id
      title  String
      hero   String?
      brands Brand[]
    }
    Copy code
    const BrandCategory = objectType({
      name: "BrandCategory",
      definition(t) {
        t.string("id");
        t.string("title");
        t.string("hero", {
          nullable: true,
        });
        t.list.field("brands", {
          type: "Brand",
          resolve: (parent) =>
            prisma.brandCategory
              .findOne({
                where: { id: String(parent.id) },
              })
              .brands(),
        });
      },
    });
    Hi all - i'm getting typescript errors on my relational BrandCategory <-> Brand object. ANy idea what I need to do to handle this PromiseLike / MaybePromise issue?
    Copy code
    Type 'Promise<Brand[]>' is not assignable to type 'PromiseLike<{...}>
    Copy code
    Type 'Promise<Brand[]>' is not assignable to type 'MaybePromise<{...}>
    j
    • 2
    • 2
  • p

    Pieter

    08/31/2020, 7:15 AM
    https://github.com/prisma/prisma/issues/3472
  • e

    ed

    09/11/2020, 3:30 PM
    Hello 👋 I’ve got a query in SQL that I’m curious is possible to write using a
    findMany
    equivalent. Imagine I want to select users in 10 buckets based on their
    id
    . Schema:
    Copy code
    model User {
      id  Int @default(autoincrement()) @id
      email String
      ...
    }
    Query: (Get me all users with an id ending in “1”)
    Copy code
    SELECT id FROM public.user
    WHERE
      id % 10 = 1
    ORDER BY id DESC
    Does this require a
    queryRaw
    or is possible with an
    IntFilter
    or some other thing I can pass into
    findMany
    ?
  • e

    Emmanuel

    09/22/2020, 5:44 PM
    Hello everyone. Please I need some help with my prisma client setup. I have the
    schema.prisma
    file with all the required info. When I run
    prisma generate
    , I expect the models defined in the schema file to create tables in the database but that’s not the case. I’m not sure if I’m missing something.
    r
    • 2
    • 3
  • g

    Gabriel Alcântara Bernardes

    10/01/2020, 8:15 PM
    how can i creating a single instance of prisma client and use in entire application for rest api?
    n
    • 2
    • 1
  • l

    Lucas Munhoz

    10/16/2020, 7:53 AM
    Hey guys, is there anyway I can forward the
    include
    argument to a wrapper class that I have around prisma and still get the dynamic types in the inferred return type? The usecase is that I have a multi tenant application, and in the upper level of the api calls we have a
    tenantId
    that we want to inject in all
    where
    arguments. Example:
    Copy code
    public find = ({ where, ...args }: FindManyProductArgs) =>
          this.prisma.product.findMany({
             where: { ...where, tenantId: this.identity.tenantId, ...args }
          })
    So this allow to safely call this function passing arguments without having to worry it will access another tenant data. But the problem is that the caller of
    find
    , when it passes includes, it doesn't correcly add the dynamic types includes. This only works if I pass the
    include
    directly to prisma instance. I can give more examples if is not clear, but my workaround to get this working is to do this: (is very ugly);
    Copy code
    public find: PrismaClient["product"]["findMany"] = ({ where, ...args }) =>
          this.prisma.product.findMany({
             where: { ...where, tenantId: this.identity.tenantId, ...args } as any
          }) as any
    I have to add
    any
    everywhere to make TS happy.
    n
    • 2
    • 3
  • t

    tatchi

    10/16/2020, 10:57 PM
    Hello, is there any documentation on how to communicate with the engine ? Let's say for example if I want to implement a client in another language ?
    n
    • 2
    • 3
  • p

    Pascal Sthamer

    10/19/2020, 1:26 PM
    Hello!
    prisma-client-js
    generates the following invalid TypeScript types when using
    t.crud.updateOne*
    for me. Notice the dots inside the type names. Has anybody else ever experienced this?
    Copy code
    export type Game_server_port.gameServerId_binding_protocol_uniqueCompoundUniqueInput = {
      gameServerId: number
      binding: number
      protocol: GameServerPortProtocol
    }
    
    export type Game_server_port.gameServerId_identifier_uniqueCompoundUniqueInput = {
      gameServerId: number
      identifier: string
    }
    
    export type Game_server_port.gameServerId_number_protocol_uniqueCompoundUniqueInput = {
      gameServerId: number
      number: number
      protocol: GameServerPortProtocol
    }
    
    export type Game_server_setting.gameServerId_gameSettingId_uniqueCompoundUniqueInput = {
      gameServerId: number
      gameSettingId: number
    }
    
    export type Game_server_setting_preset.gameServerId_name_uniqueCompoundUniqueInput = {
      gameServerId: number
      name: string
    }
    j
    • 2
    • 11
  • j

    Jared Hanstra

    10/28/2020, 4:58 AM
    hi there prisma folks - any ideas why prisma client wouldn't be able to connect to my RDS database, but prisma studio seems to be able to just fine? it's complaining that authentication failed, but i'm able to submit changes to the database in prisma studio. i re-ran
    npx prisma generate
    . i'm an AWS newbie, so maybe something is set up incorrectly there? but i'm not sure what.
    Copy code
    Authentication failed against database server at `<postgres-url>`, the provided database credentials for `<user>` are not valid.
    
    Please make sure to provide valid database credentials for the database server at `<postgres-url>`.
        at $w.request (/Users/jh/coprime/hq/node_modules/@prisma/client/runtime/index.js:212:54)
        at processTicksAndRejections (internal/process/task_queues.js:97:5) {
      code: 'P1000',
      clientVersion: '2.9.0',
      meta: {
        database_user: 'coprime',
        database_host: '<postgres-url>'
      }
    }
    m
    • 2
    • 1
  • o

    Oliver Evans

    10/30/2020, 9:14 PM
    Hi, pardon my crosspost - I thought this channel might be more appropriate than the
    graphql-nexus
    channel: I'm using nexus & the prisma 2 plugin - I'm wondering if it's possible to access the contents of
    schema.prisma
    from nexus to programmatically expose my types. Specifically, if I have the following in `schema.prisma`:
    Copy code
    model Person {
      name String
      age Int
    }
    I would like to construct the following javascript object:
    Copy code
    {
      name: "String",
      age: "Int"
    }
    Thanks!
  • b

    blocka

    11/05/2020, 2:24 PM
    Hi this is a simultaneously a prisma question and a postgres question I have a JSON field, and I sent it something simple like '{"a":1}' When I do this I get the following error:
    Copy code
    ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState("22021"), message: "invalid byte sequence for encoding \"UTF8\": 0x00", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("wchar.c"), line: Some(2017), routine: Some("report_invalid_encoding") }) }) })
    I tried to replicate this in "raw" postgres:
    Copy code
    insert into test (foo) values ('{"a":1}')
    and it fails with
    invalid input syntax for type json
    however
    Copy code
    insert into test (foo) values ('{"a": 1}')
    adding a space
    Copy code
    insert into test (foo) values ('{"a":"1"}')
    or sending a string works fine
  • u

    UddhavNavneeth

    11/08/2020, 8:03 AM
    Hi this is a doubt with respect to relations in my prisma schema. It is between User type and friend type
    type User {
      
    id: ID! @id
      
    name: String!
      
    username: String! @unique
    Copy code
    }
    type Friend {
      
    id: ID! @id
      
    user1: User! @relation(name: "FriendToUser1", onDelete: SET_NULL)
      
    user2: User! @relation(name: "FriendToUser2", onDelete: SET_NULL)
      
    status: Int!
    }
    How do set this up properly, I want to set up a field called Friends in the type User which is linked to type Friend and which Cascades onDelete. Main issue is the fact that Friend has 2 users in it because of which I am unable to set up a direct relation. Due to the current scenario I'm not being able to delete Users also as relation would get violated. Please give me recommendations.
1...567...23Latest