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

    Julien Goux

    03/17/2021, 10:13 AM
    The idea is to enforce a way to create mutations inputs
  • j

    Julien Goux

    03/17/2021, 10:14 AM
    like, always an “input” key, naming the type “<MutationName>Input”
  • j

    Julien Goux

    03/17/2021, 10:19 AM
    I’d love your input on this too @jasonkuhrt 😄
    r
    • 2
    • 5
  • j

    jasonkuhrt

    03/17/2021, 12:31 PM
    Hey @Julien Goux here's something I wrote just last week: https://gist.github.com/jasonkuhrt/04d184543efb00f558e0ac730e8ab1b1 for one of our projects. Seems to do what you want a bit more (food for thought).
    j
    • 2
    • 38
  • j

    Julien Goux

    03/22/2021, 1:49 PM
    I’m curious, when returning interfaces/union types from your graphql api, how do you typically handle the “pattern match” on your types?
  • j

    Julien Goux

    03/22/2021, 1:50 PM
    I’m using graphql-codegen with urql on the client
  • j

    Julien Goux

    03/22/2021, 1:50 PM
    right now it looks like this :
  • j

    Julien Goux

    03/22/2021, 1:50 PM
  • j

    Julien Goux

    03/22/2021, 1:50 PM
    I’m wondering if there are extra codegen plugin I could use or if it is the regular way of handling these kind of data structure
  • d

    Dregond

    03/23/2021, 5:26 AM
    Hi All
  • d

    Dregond

    03/23/2021, 5:26 AM
    I get a type error for this
    Copy code
    export const UserWithCount = objectType({
      nonNullDefaults: {
        output: true,
        input: false,
      },
      name: 'UserWithCount',
      definition(t) {
        t.int('findManyUserCount')
        t.list.field('findManyUser', {
          type: 'User',
        })
      },
    })
  • d

    Dregond

    03/23/2021, 5:27 AM
    Copy code
    import { queryField, nonNull, list } from 'nexus'
    
    export const UserFindManyWithCountQuery = queryField('findManyUserWithCount', {
      type: nonNull('UserWithCount'),
      args: {
        where: 'UserWhereInput',
        orderBy: list('UserOrderByInput'),
        cursor: 'UserWhereUniqueInput',
        distinct: 'UserScalarFieldEnum',
        skip: 'Int',
        take: 'Int',
      },
      resolve(_parent, args, { prisma, select }) {
        return {
          findManyUserCount: prisma.user.count({
            where: args.where,
          }),
          findManyUser: prisma.user.findMany({
            ...args,
            ...select.findManyUser,
          }),
        }
      },
    })
    r
    • 2
    • 2
  • d

    Dregond

    03/23/2021, 5:37 AM
    Copy code
    $ yarn tsc
    yarn run v1.22.5
    $ D:\Work\NodeJS\warehouse\backend\node_modules\.bin\tsc
    src/graphql/User/queries/findWithCount.ts:13:3 - error TS2322: Type '(_parent: {}, args: { cursor?: { email?: string; id?: number; }; distinct?: "id" | "name" | "createdAt" | "email" | "password"; orderBy?: { createdAt?: "asc" | "desc"; email?: "asc" | "desc"; id?: "asc" | "desc"; name?: "asc" | "desc"; password?: "asc" | "desc"; 
    }[]; skip?: number; take?: number; where?: { ...; }; }...' is not assignable to type 'FieldResolver<"Query", "findManyUserWithCount">'.
      Type '{ findManyUserCount: PrismaPromise<number>; findManyUser: PrismaPromise<User[]>; }' is not assignable to type 'MaybePromise<{ findManyUser: { createdAt: any; 
    email: string; id: number; name?: string; password: string; }[]; findManyUserCount: number; }>'.
        Type '{ findManyUserCount: PrismaPromise<number>; findManyUser: PrismaPromise<User[]>; }' is not assignable to type '{ findManyUser: { createdAt: any; email: string; id: number; name?: string; password: string; }[]; findManyUserCount: number; }'.
          Types of property 'findManyUser' are incompatible.
            Type 'Promise<User[]> & { [prisma]: true; }' is missing the following properties from type '{ createdAt: any; email: string; id: number; name?: string; password: string; }[]': length, pop, push, concat, and 28 more.
    
    13   resolve(_parent, args, { prisma, select }) {
  • r

    Robert Witchell

    03/28/2021, 3:05 AM
    Can anyone explain to me or point me to an example of setting up the makeSchema.contextType using a context.js file? I only see TypeScript tutorials and examples around the net
    ✅ 1
    r
    • 2
    • 3
  • j

    Julien Goux

    03/30/2021, 8:35 AM
    What are you using for dependency injection?
  • j

    Julien Goux

    03/30/2021, 8:36 AM
    Also, is it necessary? 😄
  • j

    Julien Goux

    03/30/2021, 8:37 AM
    I tend to rely on jest and mock at the import level but purist say that it’s not a good practise 🤔
  • j

    Julien Goux

    03/30/2021, 8:37 AM
    I’d like to have other inputs on this subject ^^
  • j

    Julien Goux

    03/30/2021, 8:38 AM
    On one hand I don’t really like class-everything-decorators approach and on the other I can’t introduce something like the Reader monad to my team 😅
    r
    • 2
    • 3
  • j

    Julien Goux

    03/30/2021, 7:58 PM
    I guess dependency injection isn’t a thing in nexus land? 😛
    r
    • 2
    • 1
  • d

    Dregond

    03/31/2021, 8:25 AM
    Anyone experienced this after building ?
    r
    • 2
    • 2
  • s

    sven

    03/31/2021, 12:00 PM
    Has someone solved this issue: https://github.com/graphql-nexus/nexus-plugin-prisma/issues/1056 I am still on prisma 2.14 because this prevents me from upgrading
    🤒 1
  • a

    Akshay Kadam (A2K)

    03/31/2021, 1:03 PM
    When I type
    Copy code
    ➜ npm add nexus-plugin-prisma @prisma/client 
    
    npm ERR! code ERESOLVE
    npm ERR! ERESOLVE unable to resolve dependency tree
    npm ERR! 
    npm ERR! While resolving: node-graphql@1.0.0
    npm ERR! Found: @prisma/client@2.20.1
    npm ERR! node_modules/@prisma/client
    npm ERR!   @prisma/client@"2.20.1" from the root project
    npm ERR! 
    npm ERR! Could not resolve dependency:
    npm ERR! peer @prisma/client@"2.19.x" from nexus-plugin-prisma@0.33.0
    npm ERR! node_modules/nexus-plugin-prisma
    npm ERR!   nexus-plugin-prisma@"*" from the root project
    npm ERR! 
    npm ERR! Fix the upstream dependency conflict, or retry
    npm ERR! this command with --force, or --legacy-peer-deps
    npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
    I had the above error. I fixed it with
    --legacy-peer-deps
    but then I run my app, I get the following error:
    Copy code
    TypeError: debugLib is not a function
        at Object.<anonymous> (~/server/node_modules/.prisma/client/index.js:21:15)
        at Module._compile (node:internal/modules/cjs/loader:1108:14)
        at Module._compile (~/server/node_modules/source-map-support/source-map-support.js:547:25)
        at Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
        at Object.nodeDevHook [as .js] (~/server/node_modules/ts-node-dev/lib/hook.js:63:13)
        at Module.load (node:internal/modules/cjs/loader:973:32)
        at Function.Module._load (node:internal/modules/cjs/loader:813:14)
        at Module.require (node:internal/modules/cjs/loader:997:19)
    are my
    package.json
    versions okay?
    Copy code
    "dependencies": {
        "@prisma/client": "^2.20.1",
        "apollo-server": "^2.22.2",
        "graphql": "^15.5.0",
        "graphql-scalars": "^1.9.0",
        "nexus": "^1.0.0",
        "nexus-plugin-prisma": "^0.33.0"
      },
      "devDependencies": {
        "nodemon": "^2.0.7",
        "prisma": "2.20.1",
        "rimraf": "^3.0.2",
        "ts-node-dev": "^1.1.6",
        "typescript": "^4.2.3"
      }
    r
    • 2
    • 12
  • a

    Akshay Kadam (A2K)

    03/31/2021, 1:36 PM
    Am I using aggregate API correctly?
    Copy code
    import { queryType } from 'nexus'
    
    export const Query = queryType({
      definition(t) {
        t.crud.blogs()
        <http://t.crud.blog|t.crud.blog>({
          alias: 'blog',
        })
        t.nonNull.field('totalSum', {
          type: 'Int',
          resolve: (_root, _args, ctx) => {
            console.log('totalSum', ctx)
            const totalSum = ctx.prisma.blog.aggregate({
              sum: {
                price: true,
              },
            })
            return totalSum
          },
        })
      },
    })
  • a

    Akshay Kadam (A2K)

    03/31/2021, 1:36 PM
    ctx.prisma
    comes
    undefined
  • a

    Akshay Kadam (A2K)

    03/31/2021, 1:37 PM
    earlier it was
    ctx.db
    but that was
    undefined
    as well (i think
    ctx.db
    api was 6 months back)
  • a

    Akshay Kadam (A2K)

    03/31/2021, 1:37 PM
    i also dont get autocompletes on
    ctx.
    r
    • 2
    • 11
  • y

    Yash Gupta

    04/01/2021, 5:01 AM
    I am not getting autocomplete on the context object with Nexus.js. Can somebody help me?
    a
    • 2
    • 2
  • y

    Yash Gupta

    04/01/2021, 5:03 AM
    Repo is at github.com/yashguptaz/lireddit-nexus
  • y

    Yash Gupta

    04/01/2021, 5:16 AM
    for replication
1...192021...25Latest