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

    Adam

    10/09/2020, 1:55 PM
    when updating
    @nexus/schema
    from
    .15
    to
    .16
    I get an error that it can't find the `prisma.yml`file when trying to run
    npx prisma generate
    , falling back to
    .15
    goes back to a working state
    r
    d
    • 3
    • 4
  • c

    chrisdrackett

    10/09/2020, 4:51 PM
    oof, I just have to say I’m super sad about the sunsetting of framework. Has anyone thought about finding a way to keep it alive via open source?
    l
    r
    a
    • 4
    • 5
  • e

    Eric Reis

    10/11/2020, 1:59 AM
    I'm having trouble with the types generated by the fieldAuthorizePlugin and connectionPlugin. The types are generated and VSCode recognizes the types and shows me no errors, but when starting the dev server I get compilation errors. Could it be a compiler setting I have to change?
    • 1
    • 1
  • m

    Mikastark

    10/13/2020, 4:15 PM
    graphql-shield or fieldAuthorizePlugin, that is the question 🤔
    s
    a
    s
    • 4
    • 13
  • r

    Ricardo Almeida

    10/14/2020, 12:22 PM
    My docker image is breaking with prisma 2.9.0 Should I open issue for prisma or nexus-prisma-plugin? 🤔
    Copy code
    internal/modules/cjs/loader.js:960
      throw err;
      ^
    
    Error: Cannot find module '@prisma/client'
    Require stack:
    - /app/dist/context.js
    - /app/dist/index.js
        at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)
        at Function.Module._load (internal/modules/cjs/loader.js:840:27)
        at Module.require (internal/modules/cjs/loader.js:1019:19)
        at require (internal/modules/cjs/helpers.js:77:18)
        at Object.<anonymous> (/app/dist/context.js:4:18)
        at Module._compile (internal/modules/cjs/loader.js:1133:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
        at Module.load (internal/modules/cjs/loader.js:977:32)
        at Function.Module._load (internal/modules/cjs/loader.js:877:14)
        at Module.require (internal/modules/cjs/loader.js:1019:19) {
      code: 'MODULE_NOT_FOUND',
      requireStack: [ '/app/dist/context.js', '/app/dist/index.js' ]
    }
    r
    • 2
    • 16
  • p

    Pieter

    10/14/2020, 4:31 PM
    I'm busy migrating from nexus framework (with prisma plugin) to nexus schema. I can't figure out why
    t.date
    does not exist. I followed the migration guide.
    Copy code
    import { asNexusMethod } from '@nexus/schema'
    import { DateTimeResolver } from 'graphql-scalars'
    
    const GQLDate = asNexusMethod(DateTimeResolver, 'date')
    GQLDate is in my
    types
    in
    makeSchema
    Copy code
    typegenAutoConfig: {
        sources: [
          {
            source: require.resolve('.prisma/client/index.d.ts'),
            alias: 'prisma',
          },
        ],
    ✔️ 1
    a
    • 2
    • 50
  • p

    Pieter

    10/14/2020, 5:32 PM
    https://github.com/graphql-nexus/schema/issues/552
  • l

    lucas

    10/14/2020, 6:00 PM
    hey there how to update prisma in my nexus project, i have 2.7, i want to upgrade to have access to feature findFirst thx 😊
    r
    j
    • 3
    • 8
  • s

    Sytten

    10/15/2020, 1:47 PM
    Not sure I understand the use case of the prisma plugin, I never needed it in any of my projects. What am I missing?
    r
    • 2
    • 1
  • l

    lucas

    10/15/2020, 2:28 PM
    Hi there, i would like to know how to use subscription in nexus to subscribe two users to their channel (chat), (actually when a new channel is created every users receive it in frontend and thats not good) here is my subscription and mutation where i use it. thanks for your help
    Copy code
    export const ChannelSubscription = subscriptionField('channel', {
      type: 'Channel',
      subscribe(_root, _args, ctx) {
        return ctx.pubsub.asyncIterator('channel')
      },
      resolve(payload) {
        return payload
      },
    })
    
      t.field('createChannel', {
          type: 'Channel',
          nullable: true,
          args: {
            receiverId: stringArg({ nullable: false }),
          },
          resolve: async (_parent, { receiverId }, ctx) => {
            const userId = getUserId(ctx)
            const channel = await ctx.prisma.channel.create({
              data: {
                users: {
                  connect: [{ id: userId }, { id: receiverId }],
                },
                visibles: {
                  create: [{ toUserId: userId }],
                },
              },
            })
            ctx.pubsub.publish('channel', channel)
            return channel
          },
        })
    w
    • 2
    • 6
  • w

    Will Fischer

    10/15/2020, 2:32 PM
    Hey all, I’ve been using the Nexus test setup examples to TDD a new app, and I ran into an issue. I managed to track down the problem and solve it, but I’d appreciate help or ideas for how to make the solution more elegant. Basically, the setup provided here will only work for the first test in a suite. All subsequent tests fail. It took me days to track down why, but it’s basically because this line
    Copy code
    serverInstance = await server.listen({ port });
    invokes a server implementation that uses a generic
    PrismaClient
    instance from your main app server. Obviously, that means that if you import or define your server or database differently in your project setup, you may experience different symptoms. My solution is basically to create a server generator function that takes an optional
    PrismaClient
    instance as an argument and use that as the database. Then in the test setup you can pass the newly created
    PrismaClient
    to the server. Without that on the server definition, every test will attempt to refer to the client created in the first test block, even after it’s been torn down.
    r
    • 2
    • 1
  • j

    jasonkuhrt

    10/15/2020, 4:59 PM
    FYI our team is taking on some Nexus issues this sprint. If you're curious check it out here: https://github.com/orgs/graphql-nexus/projects/1
    👍 4
    nexus 1
  • j

    Jonathan

    10/15/2020, 10:41 PM
    I have been curious about practices people follow with nexus regarding stuff like pagination. How do folks here implement the common filtering, searching, etc? Some interfaceType all relevant resolvers extends? Or perhaps using nexus's
    connectionPlugin
    ? Or do you redefine the arg-types each time you want to apply the usual
    give me 10 of these, where the name starts with Test
    r
    • 2
    • 2
  • k

    kitze

    10/18/2020, 1:36 PM
    sigh I was about to update a project with the nexus framework and I see that it's abandoned already 🤦 What's the recommended alternative to use with nexus schema? I'm assuming it's graphql-yoga
    r
    r
    +4
    • 7
    • 10
  • m

    Manthan Mallikarjun

    10/18/2020, 11:26 PM
    I am trying to do this:
    Copy code
    args: {
        categories: stringArg({ required: true, list: true }),
      },
    on a query field but in the resolve, category is of type:
    (string|null)[]
  • m

    Manthan Mallikarjun

    10/18/2020, 11:26 PM
    How can I make it just
    string[]
    ?
  • m

    Manthan Mallikarjun

    10/18/2020, 11:31 PM
    categories: stringArg({ required: true, list: [true] }),
    seems to work?
    r
    • 2
    • 1
  • m

    Manthan Mallikarjun

    10/19/2020, 8:25 AM
    What does nexus/prisma use to generate the docs? I see its gatsby, but was it a starter kit or something made by prisma?
    n
    • 2
    • 2
  • p

    Pascal Sthamer

    10/19/2020, 4:11 PM
    When using the prisma plugin, is there any way to limit the fields that can be updated with
    t.crud.updateOne*
    ?
    👀 1
    r
    • 2
    • 2
  • p

    Pieter

    10/20/2020, 9:22 PM
    @jasonkuhrt the changelog has a typo in it https://github.com/graphql-nexus/schema/releases/tag/v0.16.0
    nonNullsDefaults
    =>
    nonNullDefaults
    This typo actually breaks the migration guide and typescript is not even warning against it.
    j
    • 2
    • 2
  • a

    Adam

    10/22/2020, 2:39 PM
    When creating a type
    objectType
    from
    @nexus/schema
    there is a field for
    description
    on both the object and for each field. As someone consuming the graphql endpoint where could I see that
    description
    ?
  • a

    Adam

    10/22/2020, 2:40 PM
    or is it just a line to describe the code below for developers only?
    r
    • 2
    • 4
  • p

    Pieter

    10/23/2020, 5:05 PM
    We use nexus and got codegen outputs to generate typescript code with apollo hooks. We now in the process of migrating our sequelize service to prisma and decided to have it run as 2 side-by side seperate services while we migrate (got thousands of resolvers to modify). I know there's a way to code apollo client to take in a directive to specify which endpoint to call, but that directive goes in the GraphqlDocument, whic his auto generated. How do we tell our 2 services to add their own directive into the document?
    r
    • 2
    • 2
  • e

    Eric Reis

    10/25/2020, 11:25 PM
    @jasonkuhrt I upgraded to the latest version with the nonNullDefaults change and set both input and output to non-null, since that’s how I was using before, but the items of a list still default to nullable, is this expected behavior?
    r
    j
    a
    • 4
    • 9
  • i

    iki

    10/27/2020, 12:36 PM
    Hello guys! We use
    @nexus/schema@0.14.0
    with
    @prisma/client@2.1.3
    and have order model with related transaction field
    Copy code
    model Order {
      ...
      transaction Transaction
    }
    in Nexus API, it is exposed as
    Copy code
    export const Order = objectType({
      name: 'Order',
      definition(t) {
        ...
        t.model.transaction()
      },
    })
    Now in one of the queries we want to change some data on the transaction for the returned order. However, Nexus ignores the transaction field on the returned order object and always resolves it from the prisma model. The quick workaround was to duplicate the model and change it for the query, but it's awkward, requires changing schema derived TS types on frontends and breaks fronted Apollo caching for different types.
    Copy code
    export const CustomOrder = objectType({
      name: 'CustomOrder',
      definition(t) {
        ... // t.model('Order').xxx() 
        t.field('transaction', { type: 'Transaction' })
      },
    })
    
    export const order = queryField('order', {
      type: 'CustomOrder',
      args: {
        id: idArg({ required: true }),
      },
      resolve: async (_root, { id }, ctx) => coerceOrderTransaction(await getOrder(ctx, id)),
    })
    Is there any simple way to tell Nexus that we provide the resolved transaction field on given order query?
    r
    • 2
    • 2
  • a

    Awey

    10/28/2020, 3:04 AM
    I get this error whenever I try to hookup Prisma/Nexus to my NextJS app.
    Copy code
    TypeError: xs.reduce is not a function
        at Object.exports.indexBy (/Users/adam/Development/epicreact/next-todo-app/node_modules/nexus-plugin-prisma/dist/utils.js:81:19)
        at new DmmfDocument (/Users/adam/Development/epicreact/next-todo-app/node_modules/nexus-plugin-prisma/dist/dmmf/DmmfDocument.js:18:38)
        at Object.exports.getTransformedDmmf (/Users/adam/Development/epicreact/next-todo-app/node_modules/nexus-plugin-prisma/dist/dmmf/transformer.js:16:68)
        at new SchemaBuilder (/Users/adam/Development/epicreact/next-todo-app/node_modules/nexus-plugin-prisma/dist/builder.js:135:24)
        at Object.build (/Users/adam/Development/epicreact/next-todo-app/node_modules/nexus-plugin-prisma/dist/builder.js:76:21)
        at Object.onInstall (/Users/adam/Development/epicreact/next-todo-app/node_modules/nexus-plugin-prisma/dist/plugin.js:47:78)
        at /Users/adam/Development/epicreact/next-todo-app/node_modules/@nexus/schema/dist/builder.js:299:52
        at Array.forEach (<anonymous>)
        at SchemaBuilder.beforeWalkTypes (/Users/adam/Development/epicreact/next-todo-app/node_modules/@nexus/schema/dist/builder.js:293:22)
        at SchemaBuilder.getFinalTypeMap (/Users/adam/Development/epicreact/next-todo-app/node_modules/@nexus/schema/dist/builder.js:375:14)
    I got it all working with ApolloServer/ApolloClient/@nexus/schema. When I went to add Prisma support with 'nexus-plugin-prisma' I keep getting the above error.
    m
    d
    • 3
    • 7
  • a

    Adam

    10/28/2020, 4:36 PM
    I have a many to many join table that is producing an
    input
    in my
    api.graphql
    output that is empty, which then throws
    input manyToManyJoinTable
    This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason: Error: Input Object type ManyToManyJoinTable must define one or more fields. This join table does relate to another table that is using a composite ID, I'm not sure if that is throwing it off? Nevermind, I had an issue with old definitions that I forgot to change
    👍 1
  • j

    jasonkuhrt

    10/28/2020, 6:37 PM
    https://twitter.com/nexusgql/status/1321452871485935616
    fast parrot 1
    🎉 6
  • p

    Paul Hendrickson

    10/29/2020, 7:42 PM
    Changing details of this because I don’t want to use real company stuff but my PostGresSQLDB has a model like this:
    Copy code
    model customer{
      id           Int
      addressLine1 String
      addressLine2 String
      ...
      # more fields here
      ...
    }
    and I’m trying to return address as one line in my GraphQL Type. So basically trying to turn two columns in a DB to a single scalar type in GraphQL. This is what I have right now:
    Copy code
    export const customer = objectType({
      name: "customer",
      definition(t) {
        t.field("address", {
          type: "String",
          resolve: (root) => {
            return root.addressLine1 + " " + root.addressLine2;
           },
        })
      ...
      //more fields here
      ...
      })
    }
    When I run the query I get back the response I was expecting, but typescript is telling me
    Property 'addressLine1' does not exist on type '{ (lists fields of other type) }'
    so I thought of type typecasting the root argument in my
    resolve
    with an interface that matched my prisma model.
    Copy code
    interface customerSchema{
      id: number
      addressLine1: String
      addressLine2: String
      ...
      // more fields here
      ...
    }
    
    export const customer = objectType({
      name: "customer",
      definition(t) {
        t.field("address", {
          type: "String",
          resolve: (root: customerSchema) => {
            return root.addressLine1 + " " + root.addressLine2;
           },
        })
      ...
      //more fields here
      ...
      })
    }
    Which made that error go away but I’m instead getting a typescript error that says
    Type '(root: customerSchema => string' is not assignable to type 'FieldResolver<"Customer", "address">'.
    I’m getting my expected answer when I query for address, but I’m worried I’ll run into issues in the future if I continue to use this design pattern. How should I combine two columns in a DB to output as one field in GraphQL?
    r
    • 2
    • 2
  • a

    Ahmar Suhail

    10/30/2020, 11:20 AM
    hey guys, a quick question. Am trying to enable
    CORS
    on my nexus server:
    Copy code
    import { settings, use } from "nexus";
    
    settings.change({
      server: {
        cors: {
          origin: "*",
        },
      },
    });
    But when I try to make a request from the FE I get:
    Copy code
    {
      "event": "CORS does not work for serverless handlers. Settings will be ignored.",
      "level": 4,
      "path": [
        "nexus",
        "server"
      ]
    }
    Anyone know how I could fix this?
    r
    • 2
    • 14
1...121314...25Latest