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

    Corey Snyder

    09/27/2019, 9:59 PM
    When prisma generates the client, what is it using to do so exactly? The
    databasemodel.prisma
    ? The
    schema.graphql
    ? All of the resolver function definitions? I ask b/c I have a bug when starting my service and I think it’s in the generated client, so I’m trying to comment things out until I get it working again.
    Copy code
    /node_modules/graphql/language/parser.js:1433
      throw (0, _error.syntaxError)(lexer.source, token.start, "Expected ".concat(kind, ", found ").concat((0, _lexer.getTokenDesc)(token)));
      ^
    GraphQLError: Syntax Error: Expected Name, found }
        at syntaxError (/Users/coreysnyder/Development/Web/GraphQL/drone-part-picker/server/node_modules/graphql/error/syntaxError.js:24:10)
    f
    • 2
    • 1
  • k

    KJReactor

    09/27/2019, 10:06 PM
    Is there any reason why the following would return Error: Cannot return null for non-nullable field Event.id ?
    Copy code
    const res = async ( root, args, ctx ) => await ctx.prisma.updateUser({
            where: {id: promoter.id},
            data: { 
              promotions: { 
                create: [{ ...event }]
              }
            }
          })
    return res;
    c
    • 2
    • 3
  • c

    Corey Snyder

    09/28/2019, 3:50 AM
    Is it possible to query on a relationship like so:
    Copy code
    /* Given This Schema */
    type Shape{
      id: ID! @id
      square: Square @relation(name: "SquareShapeRelation", link: TABLE, onDelete: CASCADE)
      price: Float
    }
    type Square{
      id: ID! @id
      article: Article @relation(name: "SquareShapeRelation")
      area: Float
    }
    
    /* I'd like to query 
        - the first 5 Shapes
        - starting with the 6th
        - Ordered by price desc
        where {
          the Square has an area >= 5     
        }
    */
    
    // I was thinking it'd be:
    await context.prisma.shapes({
        orderBy: price_DESC,
        where: {
          square: {
            area_gte: 5
          }
        },
        skip: 5,
        first: 5,
      })
      
    // It's important that the first & skip happen AFTER the filtering on the child relation has been applied.
  • j

    joshdyck

    09/28/2019, 4:50 PM
    Is there a way to pass in PRISMA_CONFIG into docker without compose? I have to use a GUI to access docker due to security restrictions and I can only pass in individual environment variables and the multiline string from the yml compose file doesn't work in a single line input for an environment variable. I've looked at this repo (https://github.com/akoenig/prisma-docker-compose/blob/master/.prisma.env) which uses some environment variables that do not work. After trying to use these env variables with my postgres database I get this error from Prisma:
    Copy code
    Unable to load Prisma config: java.lang.RuntimeException: No valid Prisma config could be loaded.
    any ideas?
    • 1
    • 2
  • k

    KJReactor

    09/28/2019, 4:59 PM
    Why does create not automatically create the id for Event? Does anyone have an idea why the following would return Error: Cannot return null for non-nullable field Event.id ?
    Copy code
    const res = async ( root, args, ctx ) => await ctx.prisma.updateUser({
            where: {id: promoter.id},
            data: { 
              promotions: { 
                create: [{ ...event }]
              }
            }
          })
    return res;
  • j

    JamesJ

    09/28/2019, 10:05 PM
    General question: If I am hosting my own Prisma server do I need to set it up as ‘Prisma server/Workspace/Service name/Stage’? If so I don’t get how to add own hosted server into Prisma cloud. Seems a bit chicken and egg to me!
  • r

    Rayhan

    09/29/2019, 11:40 AM
    How to fix this ambiguous relationship in prisma2 datamodel?
    ø
    • 2
    • 1
  • k

    Kyle (TechSquidTV)

    09/29/2019, 11:06 PM
    Non Prisma specific. What is the proper way to hide certain queries/mutators based on role? Anyone have information on that? I like the crud operations but i don't think I want to expose most of them. I'd probably prefer a "register" "endpoint" /mutator. I may want a mutator that runs two crud operations I don't want the user to see
  • n

    nups

    09/30/2019, 2:42 AM
    the following schema is creating user id as foreign key in
    Address
    table instead of creating address id as foreign key in
    User
    table
    Copy code
    model User {
      id       String  @default(cuid()) @id
      email    String  @unique
      password String
      name     String
      gender   Gender  @default(value: null)
      address  Address?
    }
    
    model Address {
      id           String   @default(cuid()) @id
      addressLine1 String
      addressLine2 String?
      createdAt    DateTime @default(now())
      updatedAt    DateTime @updatedAt
    }
    not sure what is wrong here. Can someone please help? TIA
  • a

    Andrew O.

    09/30/2019, 6:02 PM
    Hey, I want to share an article I wrote about seeding databases with Prisma:
  • a

    Andrew O.

    09/30/2019, 6:02 PM
    https://fullstackdatasolutions.com/graphql-prisma-how-to-use-typescript-to-seed-data/
  • t

    tmoney

    09/30/2019, 7:50 PM
    Does anyone know how to use
    set
    with no items? So it works if you have two things and then take one away. But you can’t just pass it an empty array (or null, I tried), it just ignores it, and doesn’t disconnect anything. If you can’t make
    set
    disconnect everything, it kinda feels broken to even use it most of the time…
    Copy code
    query updateUser {
        updateUser (
            where: {
                id: "asdfasdlfkjasdlfkj"
            }
            data: {
                posts: {
                    set: [] // < ---- What can you pass here to disconnect all relations?
                }
            }
        ) {
            id
        }
    }
    y
    • 2
    • 3
  • l

    Levar Berry

    09/30/2019, 9:04 PM
    does anyone know if it is possible to have multiple DBs for one Prisma API endpoint? I am trying to think of how I can use Prisma for a SaaS app .. I like to have a database for each Company that is on our system.
    a
    k
    • 3
    • 5
  • k

    KJReactor

    09/30/2019, 10:00 PM
    How can I call a resolver from an other resolver?
  • a

    Adam Jacob

    09/30/2019, 10:03 PM
    just call it and pass the same arguments through
  • k

    KJReactor

    09/30/2019, 10:12 PM
    I've tried that @adam. When I do I get an error along the lines "cannot get property 'prisma' of undefined"
  • m

    manoj

    10/01/2019, 1:22 AM
    can anyone tell me what is the keyword for using a filter as below
    Copy code
    query {
      ads(filter: {
        url_has: "google"
      }) {
        response
      }
    }
    i basically want to filter out ads whose url has google in it @Adam Jacob? URL is a string here
  • a

    Arnav Verma

    10/01/2019, 4:25 AM
    Hey I'm strugging with a certain concepts in prisma since I cant find any documentation on it. I would like to create something to this effect
  • a

    Arnav Verma

    10/01/2019, 4:27 AM
    so I want to add some listing object (args.listing) into and existing array (shoppingCart.items), given a user id
  • a

    Arnav Verma

    10/01/2019, 4:28 AM
    the schema or shopping cart is something like this
  • a

    Arnav Verma

    10/01/2019, 4:28 AM
  • a

    Arnav Verma

    10/01/2019, 4:29 AM
    how do I properly connect "where: { user: { find user by id } }"
  • a

    Arnav Verma

    10/01/2019, 4:31 AM
    My abover code is giving me error and I don't know how to fix it
  • a

    Arnav Verma

    10/01/2019, 5:03 AM
    so i need something like "where: { id: { --find shopping cart id from user id-- } } "
  • m

    Morten Bo Rønsholdt

    10/01/2019, 6:39 AM
    hi! we've been working on rewriting our PHP API to Prisma 1. we're ready to launch in about 6 weeks. big question is: should we launch with Prisma 1 or start migrating to Prisma 2 now? my concern is that Prisma 2 is not ready (for production) in 6 weeks
    👀 2
    r
    m
    d
    • 4
    • 8
  • k

    KJReactor

    10/01/2019, 12:52 PM
    I don't know what your concerns are but chances are using Prisma 1 for now is the safest way to go. A ruth of thumb is to wait for new releases to mature or at least undergo an acceptable amount of testing @Morten Bo Rønsholdt
    d
    • 2
    • 1
  • a

    Artur Mrozowski

    10/01/2019, 1:51 PM
    Is it possible to define relationships that reference other fields than primary key in prisma schema?
  • t

    Tim Hardy

    10/01/2019, 2:03 PM
    How can I change the default help text that appears in GraphQL Playground? "Write your query or mutation here"
  • k

    KJReactor

    10/01/2019, 2:29 PM
    What is the best way to call a resolver inside an other? I want to keep my resolvers DRY. I've tried :
    const variable = async ( root, args, ctx ) => await [resolver]({...args}).then( res => res )
    and
    const variable = await [resolver]({...args})
    neither works
    t
    a
    • 3
    • 5
  • j

    Junsu Kim

    10/01/2019, 2:48 PM
    I want to use id as a number, not a string. Is there a way?
    k
    • 2
    • 4
1...315316317...637Latest