https://www.prisma.io/ logo
Join SlackCommunities
Powered by
# orm-help
  • j

    Jeff

    06/10/2022, 2:33 AM
    The strange thing is nothing about my code has changed -- only that I began deleting previous Vercel preview deployments that were being unused, I am not sure if that could've caused anything
    ✅ 1
    n
    • 2
    • 1
  • s

    Sam Lambert

    06/10/2022, 4:08 AM
    @Jeff if you email support@planetscale.com we can help you out
    🙌 1
  • m

    Michael Roberts

    06/10/2022, 8:22 AM
    Hey, let’s say we have a field which is an enum … e.g.,
    type AccountType @default(DEFAULT)
    does anyone know how this could work with zod?
    ✅ 1
    a
    • 2
    • 2
  • f

    FUTC

    06/10/2022, 10:11 AM
    How can I add wildcards to a Full-Text search in prisma when using Postgres? When I search for
    test
    I only find
    test org
    from my db but not the other entries with the name
    test2 org
    and
    test3 org
    Edit: just found the
    contains
    operator which seems to work. What is the difference between the full text search and something like the contains operator when searching a column?
    ✅ 1
    n
    • 2
    • 1
  • m

    Michael Roberts

    06/10/2022, 10:28 AM
    Hey all, upgrading to 3.15.1 I am seeing the following bug:
    👀 1
    r
    • 2
    • 1
  • m

    Michael Roberts

    06/10/2022, 10:28 AM
    Copy code
    node_modules/.prisma/client/index.d.ts(6,26): error TS2307: Cannot find module '@prisma/client/runtime/proxy' or its corresponding type declarations.
  • c

    Charles Gaudreau Jackson

    06/10/2022, 3:49 PM
    Hi! What great full-stack web dev courses are there out there? Thank you
    ✅ 1
    n
    • 2
    • 3
  • j

    Jose Maria CL

    06/10/2022, 7:08 PM
    Is the Prisma Open CRUD specification supported yet? https://www.opencrud.org/ Hi there! My team and I are working defining some criteria objects (with TS) to describe the supported filters of our “search” methods because we are trying to follow the repository pattern described in this article to be able to decouple our application and domain services from the prisma 3 implementation (migrating from prisma 1 to 2 was painful and we learned the lesson) As I remember, the prisma client API were based on the Prisma Open CRUD specification and we want to use it to base our criterion objects. Is this initiative active or even supported?? Is there a new version or a new CRUD specification?? Thanks!
    👆 1
    ✅ 1
    n
    • 2
    • 2
  • g

    Gezim

    06/10/2022, 7:42 PM
    Hi folks. I’m in need of some help. Relevant schema parts
    Copy code
    model ShopifyOfflineStoreSession {
      pk          String    @id(map: "PK_d371917bab72a48d6cce7880fc5") @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
      id          String    @unique(map: "UQ_91ede9e23efbd7ee27b37bdd9ba") @db.VarChar
      store       Store?    @relation(fields: [pk], references: [shopifyOfflineSessionPk], onDelete: Cascade, onUpdate: Cascade, map: "FK_901a837fbbf20119aded3682f90")
    
      @@map("shopify_store_session")
    }
    
    
    model Store {
      id                       Int                         @id(map: "PK_f3172007d4de5ae8e7692759d79") @default(autoincrement())
      shopifyOfflineSessionPk  String?                     @unique(map: "UQ_901a837fbbf20119aded3682f90") @db.Uuid
      shopifyOfflineSession    ShopifyOfflineStoreSession?
    
      @@map("store")
    }
    This query fails:
    Copy code
    await this.prisma.shopifyOfflineStoreSession.create({
            data: {
              ...session,
              store: { connect: { id: store.id } },
            },
          });
    Error:
    Copy code
    db     | 2022-06-10 16:41:02.035 UTC [15541] ERROR:  null value in column "pk" violates not-null constraint
    db     | 2022-06-10 16:41:02.035 UTC [15541] DETAIL:  Failing row contains (null, <http://offline_subbooks2.myshopify.com|offline_subbooks2.myshopify.com>, 2022-06-10 16:41:02.033, 2022-06-10 16:41:02.033, null, <http://subbooks2.myshopify.com|subbooks2.myshopify.com>, <some long number here>, f, null, null, null).
    db     | 2022-06-10 16:41:02.035 UTC [15541] STATEMENT:  INSERT INTO "public"."shopify_store_session" ("pk","id","createdAt","updatedAt","shop","state","isOnline") VALUES ($1,$2,$3,$4,$5,$6,$7) RETURNING "public"."shopify_store_session"."pk"
    api    | Issue saving Shopify offline token. Err: PrismaClientKnownRequestError:
    api    | Invalid `this.prisma.shopifyOfflineStoreSession.create()` invocation in
    api    | /usr/src/api/src/store/store.service.ts:576:52
    api    |
    api    |    573     data: session,
    api    |    574   });
    api    |    575 } else {
    api    | →  576   await this.prisma.shopifyOfflineStoreSession.create(
    api    |   Null constraint violation on the fields: (`pk`)
    api    |     at cb (/usr/src/api/node_modules/@prisma/client/runtime/index.js:38683:17) {
    api    |   code: 'P2011',
    api    |   clientVersion: '3.6.0',
    api    |   meta: { constraint: [ 'pk' ] }
    api    | }
    api    | query: DELETE FROM "store" WHERE "id" IN ($1) -- PARAMETERS: [18]
    I don’t understand why prisma is setting
    pk
    on
    shopifyOfflineStoreSession
    to null. Can someone help me understand what’s causing this error?
    👀 1
    r
    j
    +2
    • 5
    • 16
  • m

    Morritz

    06/10/2022, 8:02 PM
    Does prisma currently have support for db triggers?
    👀 1
    a
    • 2
    • 2
  • m

    Michael Roberts

    06/11/2022, 9:47 AM
    Hey - asked here before but it kind of became drowed out in other questions - can we setup atomic transactions and rollback / commit as needed? It would be nice to run tests on a lot of functionality but equally it would be nice to run them in isolation and rollback when complete…are there any methods or processes for this?
    👀 1
    a
    • 2
    • 2
  • h

    Halvor

    06/11/2022, 12:52 PM
    Is there a way to get count of entries returned from a where?
    ✅ 1
    n
    • 2
    • 1
  • h

    Halvor

    06/11/2022, 1:06 PM
    I want to remove duplicates on a column in my query and get the number of rows returned.
    ✅ 1
    n
    • 2
    • 1
  • h

    Halvor

    06/11/2022, 1:12 PM
    Copy code
    const result = await prisma.stat.count({
        by: ["userId"]
    });
    ✅ 1
    n
    • 2
    • 3
  • h

    Halvor

    06/11/2022, 1:12 PM
    How can i do this? the groupBy function will return count per result, not over all of them
  • p

    Philippe Sabourin

    06/11/2022, 1:46 PM
    Anyone seen it where
    prisma db push
    and
    prisma studio
    work fine, but within the app, it gives me this error:
    Copy code
    prisma:info Starting a mssql pool with 13 connections.
    prisma:info Performing a TLS handshake
    prisma:warn Trusting the server certificate without validation.
    prisma:info TLS handshake successful
    prisma:error Login failed for user 'giqconnect'.
    The same URL for all 3, also using the same URL in another app and it works fine there.
    ✅ 1
  • p

    Philippe Sabourin

    06/11/2022, 2:11 PM
    I figured it out, there was a $ in the password that was read fine in most cases, but not by NextJS's newest version of .env file reader.
    ✅ 1
    n
    • 2
    • 1
  • a

    Amresh Prasad Sinha

    06/11/2022, 4:03 PM
    Hey 👋 I am getting error while using
    findUnique
    . Here are the logs: https://pastebin.com/nXeCa109 I can't figure out why its not working 😕
    ✅ 1
    n
    • 2
    • 3
  • b

    Berian Chaiwa

    06/11/2022, 7:01 PM
    Hello here. Any one using
    graphql-shield
    to help me with this basic setup? I tried the below rule/permission setup but it is not being invoked no matter what:
    rule.ts
    Copy code
    import { rule, and, or, not } from "graphql-shield";
    import { GraphQLContext } from "..";
    
    const isValidInvitation = rule()(
      async (parent, args, ctx: GraphQLContext, info) => {
        console.log("parent", parent);
        console.log("args", args);
        console.log("ctx", ctx);
    
        return false;
      }
    );
    
    export default { isValidInvitation };
    permissions/index.ts
    Copy code
    import { shield } from "graphql-shield";
    import rules from "./rules";
    
    const permissions = shield({
      Mutation: {
        createInvitedUser: rules.isValidInvitation,
      },
    });
    
    export default permissions;
    src/index.ts
    Copy code
    import { applyMiddleware } from "graphql-middleware";
    import { schema } from "./api/schema";
    import permissions from "./permisions";
    
    const secureSchema = applyMiddleware(schema, permissions);
    ...
    startApolloServer(secureSchema, prisma);
    My schema is pretty big and I want to test protecting a type/resolver at a time. Any ideas? Thanks.
    ✅ 1
    n
    • 2
    • 3
  • n

    Nathaniel Babalola

    06/11/2022, 7:51 PM
    Does Prisma have hooks ? If not, should we be expecting it ?
    ✅ 1
    n
    • 2
    • 1
  • a

    Aurora

    06/12/2022, 4:38 AM
    Why I can only use id to search user? I want to search it by email
    ✅ 1
  • a

    Aurora

    06/12/2022, 5:10 AM
    Although I add @unique to email field, I doesn't work too
    ✅ 1
    🪱 1
    c
    r
    • 3
    • 8
  • t

    TheLegend29

    06/12/2022, 3:22 PM
    Hello, i’m just install this library https://github.com/prisma-labs/get-graphql-schema. and cannot generate file. Can someone help me with this. Huge appreciate
    👀 1
    n
    • 2
    • 1
  • g

    Gelo

    06/12/2022, 4:33 PM
    Return becomes Promise<{}> when I assign the select type on a variable but if directly specify on the select query the type is correct
    👀 1
    ✅ 1
    n
    • 2
    • 9
  • k

    kyler

    06/13/2022, 1:58 AM
    Hey folks, i was wondering if anyone knows how I could pull off a count that factors in a relation? say user and posts. e.g count how many users have posts?
    ✅ 1
    n
    • 2
    • 3
  • b

    Berian Chaiwa

    06/13/2022, 10:01 AM
    What type of error does Prisma throw when
    RejectOnNotFound
    is configured? I am trying to catch it like below but it is always escaping me:
    Copy code
    catch (error) {
        if (error instanceof PrismaClientKnownRequestError) {
          throw new AuthenticationError(error.name);
        } else if (
          error instanceof
          (PrismaClientUnknownRequestError || PrismaClientValidationError)
        ) {
          throw new AuthenticationError(error.message);
        }
        // Otherwise send to Sentry so we can debug
        console.log("Authentication Error", error);
        throw new ApolloError("INTERNAL SERVER ERROR", "INTERNAL_SERVER_ERROR");
      }
    i
    a
    • 3
    • 7
  • p

    Pieter

    06/13/2022, 11:13 AM
    pnpm + prisma + docker
    j
    r
    • 3
    • 12
  • o

    Oliver St.

    06/13/2022, 11:18 AM
    With the newest version of pnpm (7.2.1) I get an error with the prisma client package name:
    ERR_PNPM_BAD_PACKAGE_JSON  ****/pnpm-workspace-template/libs/prisma/node_modules/@prisma/client/package.json: Invalid name: “.prisma/client”
    So pnpm doesn’t allow package names starting with a dot
    .
    Does a fix exist or is this a new issue?
    r
    • 2
    • 8
  • b

    Brendan Allan

    06/13/2022, 12:51 PM
    In the Prisma engines, shouldn’t a null serialisation error be returned if a query has no items to return and is not optional? I have a feeling this is is a case of simply forgetting a negation and that the second
    && opt
    should be
    && !opt
    . The potential mistake is
    query-engine/core/src/response_ir/internal.rs
    line 267
    ✅ 1
    n
    • 2
    • 1
  • b

    Berian Chaiwa

    06/13/2022, 2:07 PM
    Anyone to show me how to correctly setup
    express-jwt
    with
    Express Apollo Server
    ? I can't figure out why jwt verification errors are not being thrown back to Apollo. I see
    express-jwt
    logging the error but never received in Apollo Studio Explorer. I am using it like this but I can't figure out how to blend it into the Apollo/GraphQL error handling loop. Should I apply it as schema middleware or just as a regular express request middleware?:
    Copy code
    export function createContext(
      req: JWTRequest,
      prismaClient: PrismaClient
    ): GraphQLContext {
      return {
        req,
        prisma: prismaClient,
      };
    }
    
    async function startApolloServer(
      gqlSchema: GraphQLSchema,
      prismaClient: PrismaClient
    ) {
      dotenv.config();
    
      const app = express();
       // here is how I am using it but when token is invalid it prevents request from proceeding(which is okay) but the errors are not sent back to Apollo Studio Explorer like any other errors raised by resolvers.
      app.use(
        expressjwt({
          secret: process.env.JWT_SECRET!,
          algorithms: ["HS256"],
          credentialsRequired: false,
        })
      );
    
      // 1. Http Server
      const httpServer = http.createServer(app);
    
      // 2. Websocket Server
      const wsServer = new WebSocketServer({
        server: httpServer,
        path: "/",
      });
    
      const wsServerCleanup = useServer({ schema: gqlSchema }, wsServer);
    
      // 3. Apollo Server
      const server = new ApolloServer({
        schema,
        context: ({ req }) => {
          return createContext(req, prismaClient);
        },
        csrfPrevention: true,
        plugins: [
          // Proper shutdown for the HTTP server.
          ApolloServerPluginDrainHttpServer({ httpServer }),
    
          // Proper shutdown for the websocket server
          {
            async serverWillStart() {
              return {
                async drainServer() {
                  await wsServerCleanup.dispose();
                },
              };
            },
          },
        ],
      });
    
      await server.start();
      server.applyMiddleware({
        app,
      });
    
      await new Promise<any>((resolve: any) =>
        httpServer.listen({ port: process.env.PORT }, resolve)
      );
      console.log(`🚀 Server ready at <http://localhost:4000>${server.graphqlPath}`);
    }
    ✅ 1
    • 1
    • 1
1...585586587...637Latest