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

    Albert Gao

    09/07/2020, 6:10 AM
    How to debug Nexus with Source map support? https://nexusjs.org/guides/recipes#with-vs-code Followed the doc but does not work
    r
    • 2
    • 2
  • m

    mikkelsl

    09/07/2020, 2:57 PM
    Is there anything I can do to help speed up upgrading nexus-plugin-prisma to use prisma 2.6.2? Really would love to start using features from 2.5 and 2.6, but 2.6.1 has problems with dates šŸ™‚
    šŸ‘ 2
    a
    s
    +2
    • 5
    • 8
  • m

    Matt

    09/09/2020, 12:38 AM
    I can't find an example where a type is using enums set in the mySQL db. Is there one that I'm missing?
    r
    • 2
    • 7
  • m

    Michael

    09/09/2020, 10:29 AM
    hi volks, I am currently using the nexus framework and I built a middleware to check the authorization for my graphql queries. What is the best practise if I want to send an error on res to the client? Do I use
    ctx.res
    or like in Apollo Server
    return new AuthenticationError("Not authorised");?
    I couldn’t find anything about it in the nexus documentation.
    a
    • 2
    • 2
  • w

    Wade Tandy

    09/10/2020, 9:45 PM
    Hi all. I'm experimenting with moving an existing project over to prisma + nexus. In our project, every data item is scoped to a customer. Our previous implementation adds an automatic scoping to our queries so that if i did
    Copy code
    context.setCustomer('1234')
    
    //... later on
    
    post.findOne({id: 5678})
    the resulting query would be
    Copy code
    SELECT * FROM posts
    WHERE id = 5678 AND customer_id = 1234
    This will work no matter where I do the query, as long as it is in the context of a request that has run
    setCustomer
    , which allows our resolvers to not worry about missing an important scoping of user data. Can anyone think of a way this can be done with prisma + nexus?
    a
    r
    • 3
    • 5
  • k

    Kohki Shiga

    09/13/2020, 4:26 AM
    Hi. I'm a beginner of nexus and I use graphql-nexus and prisma for my personal project. I am stuck with this error for quite a while and I would appreciate if anyone has any idea. Error:
    Copy code
    The change you are trying to make would violate the required relation 'DrinkingLocationsToUser' between the `DrinkingLocations` and `User` models.
    Prisma/schema.prisma
    Copy code
    model User {
      id               String            @default(cuid()) @id
      username         String
      password         String
      drinkingLocation DrinkingLocations
      profile          Profile
    }
    
    model DrinkingLocations {
      id           String   @default(cuid()) @id
      locationName String
      longtitude   Float
      latitude     Float
      createdAt    DateTime @default(now())
      user         User     @relation(fields: [userId], references: [id])
      userId       String
    }
    graphql/schema.ts (Nexus side)
    Copy code
    schema.objectType({
      name: 'User',
      definition(t) {
        t.string('id', { description: 'Id of the user' });
        t.string('username', { description: 'Name of the user' });
        t.string('password', { description: 'Encrypted password' });
        t.field('DrinkingLocations', {
          type: 'DrinkingLocations',
        });
        t.field('Profile', {
          type: 'Profile',
        });
      },
    });
    
    schema.objectType({
      name: 'DrinkingLocations',
      definition(t) {
        t.string('id', { description: 'Id of the Drinking location' });
        t.string('locationName', { description: 'Name of the Drinking Location' });
        t.float('longtitude', { description: 'Longtitude of the Drinking ' });
        t.float('latitude', { description: 'Latitude of the Drinking Location' });
        t.date('createdAt', { description: 'Time when the user started drinking' });
        t.string('userId', { description: 'Foreign key to User' });
        t.field('user', {
          type: 'User',
        });
      },
    });
    
    schema.mutationType({
      definition(t) {
        t.crud.createOneUser();
        t.crud.createOneDrinkingLocations();
        t.crud.createOneProfile();
      },
    });
    r
    • 2
    • 4
  • v

    Venu

    09/14/2020, 9:52 AM
    Hi Folks, do we have production ready examples for nexus-graphql
    n
    • 2
    • 3
  • p

    Pieter

    09/15/2020, 4:29 PM
    How does one use graphql middleware with nexus framework?
    r
    • 2
    • 20
  • k

    Kohki Shiga

    09/16/2020, 9:23 AM
    Hi. I have a few questions regarding nexus-graphql again. I'm wondering why I'm getting null value for the field where I'm expecting a list of ToMail objects. The two entities (Mail and ToMail) should be connected by toEmailId. I appreciate any insights.
    b
    r
    • 3
    • 22
  • p

    Pieter

    09/16/2020, 10:58 AM
    Reflection fails with exit code 1 and no additional info https://github.com/graphql-nexus/nexus/issues/1381 If anyone can help with this blocker. I'd appreciate it
    r
    • 2
    • 7
  • p

    Pieter

    09/16/2020, 1:17 PM
    Apollo Engine in Nexus
    r
    • 2
    • 7
  • l

    lewebsimple

    09/17/2020, 3:45 AM
    Anybody working on getting nexus-plugin-prisma to work with 2.7.1 ?
  • l

    lewebsimple

    09/17/2020, 3:46 AM
    https://github.com/graphql-nexus/nexus-plugin-prisma/pull/837
  • l

    lewebsimple

    09/17/2020, 3:46 AM
    ##[error]src/framework/settings.ts(2,54): error TS2307: Cannot find module '@prisma/client/runtime/getPrismaClient' or its corresponding type declarations.
  • l

    lewebsimple

    09/17/2020, 3:49 AM
    It seems
    @prisma/client/runtime
    exports everything from index.d.ts in version 2.7.1 (i.e. no .../runtime/getPrismaClient.d.ts)
  • l

    lewebsimple

    09/17/2020, 3:49 AM
    And
    interface GetPrismaClientOptions
    is not exported šŸ˜ž
    r
    a
    • 3
    • 2
  • m

    Michael Gardner

    09/17/2020, 6:40 PM
    anyone have advice on running parallel test suites in jest without making multiple server instances, or getting said instances to run on different ports? I’ve followed the tutorial to set it up but it only uses one test suite and when you have multiple, you get multiple node servers spawn on the same port causing some tests to fail due to their instance waiting for the port to be freed up. from what the example shows, it encourages you to setup a temporary schema with a guid appending to the end, which results in multiple databases running in one instance when running test suites in parallel. this is fine, not best, because it’s all one test user accessing the database client, but it eats up resources and doesn’t mock real conditions.
    t
    r
    • 3
    • 9
  • j

    Justin Voitel

    09/18/2020, 12:09 AM
    Anyone else using nexus with pnpm? Nexus dev works but build throws errors where it can’t find any package in node_modules
    r
    • 2
    • 2
  • t

    Thevy N

    09/18/2020, 7:30 AM
    Hi! I'm trying to use include filter in a prisma query but its getting ignored when i query from a client (playground) and prints everything. If i console.log the result it works the way it's supposed to. What's the problem? I used this query and all published posts gets returned from the playground.
    Copy code
    return ctx.prisma.user.findMany({
              where: {
                email: {
                  contains: '<http://prisma.io|prisma.io>',
                },
              },
              include: {
                posts: {
                  where: {
                    published: false,
                  },
                },
              },
              orderBy: {
                name: 'asc',
              },
            })
    r
    • 2
    • 8
  • a

    Albert Gao

    09/19/2020, 5:34 AM
    Confused about the test in nexus doc. What does it try to test here, what is the point of sending the 1st request when the result is not been used later? Why the 2nd statement send a request with user {} which is different than the 1st statement?
    šŸ’Æ 1
    r
    • 2
    • 1
  • a

    Albert Gao

    09/19/2020, 7:17 AM
    also, for the
    Without a database
    option, is there an in-memory database? How to seed it?
    r
    • 2
    • 3
  • a

    Albert Gao

    09/20/2020, 4:58 AM
    Following the doc here: https://nexusjs.org/guides/testing But the
    delet
    in
    afterAll
    is not working:The user is still in the database, what I did wrong?
  • a

    Ahmar Suhail

    09/21/2020, 3:23 PM
    Copy code
    [4:22 PM] prisma:query SELECT "public"."conversations"."uuid", "public"."conversations"."booking_id", "public"."conversations"."created", "public"."conversations"."event_request_id", "public"."conversations"."last_message_timestamp", "public"."conversations"."supplier_id", "public"."conversations"."updated" FROM "public"."conversations" WHERE ("public"."conversations"."last_message_timestamp" IS NOT NULL AND "public"."conversations"."supplier_id" = $1) ORDER BY "public"."conversations"."last_message_timestamp" DESC, "public"."conversations"."uuid" ASC OFFSET $2
    prisma:query SELECT "public"."conversations_messages"."uuid", "public"."conversations_messages"."content", "public"."conversations_messages"."conversation_id", "public"."conversations_messages"."created", "public"."conversations_messages"."old_message_id", "public"."conversations_messages"."sender_user_id", "public"."conversations_messages"."type", "public"."conversations_messages"."updated", "public"."conversations_messages"."conversation_id" FROM "public"."conversations_messages" WHERE "public"."conversations_messages"."conversation_id" IN ($1) ORDER BY "public"."conversations_messages"."created" DESC, "public"."conversations_messages"."uuid" ASC OFFSET $2
    [
      {
        content: "Hello Hello",
        conversation_id: '160ad9a9-56e6-4894-a2a7-94200a03c2c0',
        created: 2020-09-19T21:46:20.150Z,
        updated: 2020-09-19T21:46:20.150Z,
        uuid: '19eb6f94-9a04-4603-853b-f5ccf37f3524'
      },
    ]
    // These queries are executed after console.log
    prisma:query SELECT "public"."conversations"."uuid" FROM "public"."conversations" WHERE "public"."conversations"."uuid" = $1 LIMIT $2 OFFSET $3
    prisma:query SELECT "public"."conversations_messages"."uuid", "public"."conversations_messages"."content", "public"."conversations_messages"."conversation_id", "public"."conversations_messages"."created", "public"."conversations_messages"."old_message_id", "public"."conversations_messages"."sender_user_id", "public"."conversations_messages"."type", "public"."conversations_messages"."updated", "public"."conversations_messages"."conversation_id" FROM "public"."conversations_messages" WHERE "public"."conversations_messages"."conversation_id" IN ($1) OFFSET $2
    The resolver seems to be returning data from these second set of queries instead of the first and I can't figure out what's causing the second set of queries to execute? Any help would be really appreciated! :)
  • a

    Ahmar Suhail

    09/21/2020, 3:23 PM
    Hey guys, I'm using prisma & nexus-prisma-plugin. Facing a problem when I'm trying to order entries in a related schema and was hoping someone could help. I have two tables: conversations & conversation messages.
    Copy code
    model conversations {
      created                DateTime?
      last_message_timestamp DateTime?
      supplier_id            String?
      uuid                   String                   @id
      conversations_messages conversations_messages[]
    }
    
    model conversations_messages {
      content                     String
      conversation_id             String
      created                     DateTime?
      sender_user_id              String
      uuid                        String                           @id
      conversations               conversations                    @relation(fields: [conversation_id], references: [uuid])
    I want to get all conversations a supplier has, and last received message in each conversation_id.Ā  For this, I've written a custom resolver:
    Copy code
    schema.extendType({
      type: 'Query',
      definition(t) {
        t.crud.conversations({filtering: true, ordering: true})
        t.list.field('supplierConversations', {
          type: "conversations",
          args: {
            supplier_id: schema.stringArg() 
          },
          resolve: async(_root, args, ctx) => {
            const x = await ctx.db.conversations.findMany({
              where: {
                supplier_id: { equals: args.supplier_id },
                last_message_timestamp: {not: null}
              },
              orderBy: {
                last_message_timestamp: 'desc'
              },
              include: {
                conversations_messages: {
                  orderBy: {created: 'desc'},
                }
              }
            })
    
            console.log(x[0].conversations_messages);
    
            return x;
          }
        })
      },
    })
    And my graphQl query is
    Copy code
    {
      supplierConversations(supplier_id: "001C768B-6BD6-4C87-90E1-E8C7B9A580C4") {
        conversations_messages {
          created
        }
      }
    }
    However, this doesn't return the expected result. When I do console.log(x[0].conversations_messages), the messages are in the correct order (with the most recent created date being first). But data returned by this resolver is not in this format. Two additional queries are executed after the console.log statement. Logging prisma queries gives the following output:
    r
    • 2
    • 5
  • i

    iloveprisma

    09/22/2020, 8:37 AM
    https://github.com/prisma/prisma-examples/tree/latest/typescript/graphql-nextjs I downloaded the prisma example from github. Through this example I tried Filter within include and got unexpected results. On the server side, the value came out correctly, but on the client side, the wrong value came out. Can someone help me out?
  • i

    iloveprisma

    09/22/2020, 8:37 AM
  • i

    iloveprisma

    09/22/2020, 8:38 AM
  • i

    iloveprisma

    09/22/2020, 8:38 AM
    client
  • i

    iloveprisma

    09/22/2020, 8:46 AM
    r
    • 2
    • 8
  • a

    Ahmar Suhail

    09/22/2020, 11:30 AM
    I have nexus model like:
    Copy code
    schema.objectType({
      name: 'conversations',
      definition(t) {
        t.model.uuid()
        t.model.conversations_messages({ ordering: true })
        t.model.conversations_users()
        t.model.last_message_timestamp()
        t.model.event_requests()
        t.int('unreadCount', {
          args: {
            supplier_id: schema.stringArg(),
            user_id: schema.stringArg() 
          },
          resolve: (conversation, args, ctx) => {
           //dummy return value 
           return 5
          }
        })
      }
    })
    I want to get all conversations which have unreadCount as 0. Is it possible to filter based on a field which is calculated through a custom resolver?
1...91011...25Latest