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

    Andrew Ross

    10/06/2021, 5:30 PM
    what is the best way to execute schema stitching with prisma+nexus in nextjs? I'd like to tie a headless graphql endpoint in with my prisma endpoint for a CRM I'm building out -- specifically OneGraph apollo federation is an option but I'm looking for a more direct graphql-binding solution. Any tips would be greatly appreciated node parrot
  • a

    Andrew Ross

    10/06/2021, 5:45 PM
    answered my own question 😅 https://www.npmjs.com/package/next-graphql
  • d

    Dante

    10/07/2021, 2:15 AM
    While the prisma supports TypeInput so that I have no need to create DTO file when it comes to nestjs + prisma, nexus + prisma wants me to write inputObjectType. I think this is a point to be improved. I know nexus-plugin-prisma but it seems almost deprecated. 😞 Any Idea on creating inputObjectType from Prisma schema?
  • a

    Andrew Ross

    10/07/2021, 3:10 AM
    https://nexusjs.org/docs/api/input-object-type
    👎 1
  • j

    Josef Henryson

    10/11/2021, 1:50 PM
    I’m migrating from Prisma 1.34 to Prisma 3.2.0 and in my current setup I have several types like “XxxWhereInput” for my Xxx types… When I generate types with nexus-prisma I get the type Xxx from my prisma model, but not associated WhereInput etc. Should I add these to my Prisma model to have them generated for nexus? Or should I declare them myself in nexus schema directly? Or can I have them generated in some other way?
    s
    • 2
    • 10
  • j

    Josef Henryson

    10/12/2021, 9:56 AM
    I try to generate types with paljs from my schema which has json propertys, but the generated code gives me this error: Property ‘json’ does not exist on type ‘Omit<OutputDefinitionBlock<“User”>, “nonNull” | “nullable”>’. t.nullable.json(‘info’) When I inspect the nexus types it does not contain the json property indeed. Can I generate this in some way? What do I miss?
  • s

    Steven

    10/12/2021, 10:52 AM
    @Josef Henryson I have some fields on a model which are json but I don’t have any problems with:
    Copy code
    t.field(PrismaModel.myJsonFieldNameHere)
  • s

    Steven

    10/12/2021, 10:57 AM
    After looking, you will get the various types created for you once I think you’ve configured the plugin correctly - I was originally using the package nexus-prisma/scalars in the root import, but after generating I got conflicts so now only use the “Bytes” type and the rest are auto created for me
  • j

    Josef Henryson

    10/12/2021, 12:02 PM
    Hmm, yeah I guess it is some conf issue, I just don’t have a clue on how to configure it for me…
  • j

    Josef Henryson

    10/12/2021, 12:10 PM
    In my generated nexus-prisma code I can see this: type: ‘Json’ extends NexusCore.GetGen<‘allNamedTypes’, string> ? NexusCore.NexusNullDef<‘Json’> : ’Warning/Error: The type \‘Json\’ is not amoung the union of GetGen<\‘allNamedTypes\’, string>. This means that either: 1) You need to run nexus typegen reflection. 2) You need to add the type \‘Json\’ to your GraphQL API.' It seems like it checks whether NexusCore has the Json type defined. I’ll try to see if I can run the nexus typegen reflection.
  • j

    Josef Henryson

    10/15/2021, 7:59 AM
    In my current setup of nexus/prisma etc I have for example a generated query users() - but after migrating my generated graphql from nexus gives me findManyUsers() instead… Do you know why this is the case? Is it a later version of nexus, or a change in the graphql “standard”? EDIT: Perhaps it is that I use paljs instead of nexus-prisma that is the reason…? 🤔
    r
    a
    • 3
    • 2
  • a

    Akshay Kadam (A2K)

    10/20/2021, 1:26 PM
    I get a weird error with my current
    npm
    script:
    Copy code
    TypeError: chalk_1.default.Instance is not a constructor
        at Object.<anonymous> (~/my-app/node_modules/@nexus/logger/src/chalk.ts:9:22)
    The
    npm
    script looks like:
    Copy code
    cross-env GENERATE=true cross-env DOTENV_CONFIG_PATH=.env.example ts-node -r tsconfig-paths/register --require dotenv/config --transpile-only -P nexus.tsconfig.json src/server/graphql/schema.ts
  • a

    Akshay Kadam (A2K)

    10/20/2021, 1:26 PM
    Not sure how to solve this as I've been trying for hours.
  • a

    Akshay Kadam (A2K)

    10/20/2021, 1:28 PM
    This used to work with
    nexus-plugin-prisma
    but now I've opted for
    nexus-prisma
    & it stopped working. I did change the underlying code but I can't find a complete example of
    nexus-prisma
    anywhere on Github. I mean there are hardly few repos but none of them work for me
  • a

    Akshay Kadam (A2K)

    10/20/2021, 1:29 PM
    I get error on
    @nexus/logger
    which is a sub-dependency of:
    Copy code
    └─┬ nexus-prisma@0.34.0
      └─┬ setset@0.0.7
        └── @nexus/logger@0.2.0
  • a

    Akshay Kadam (A2K)

    10/20/2021, 1:35 PM
    The script above was called
    generate:nexus
    so does that mean I can remove the script completely because
    nexus-prisma
    's generator is called in
    schema.prisma
    ?
    r
    l
    • 3
    • 4
  • j

    Josef Henryson

    10/21/2021, 3:50 PM
    Maybe a stupid question. But I’m quite new to typescript so bear with me please… If I have type User that is generated by prisma and I then extend it with Nexus (extendType): - how can I elsewhere refer to this extended User type and get all it’s fields etc?
    r
    • 2
    • 7
  • j

    Josef Henryson

    10/21/2021, 4:10 PM
    I can of course find it in the generated nexus.ts, but it feels like Catch 22 if I from other schema defining code needs to refer to types that might not yet have been generated.
  • p

    Patrick

    10/21/2021, 9:50 PM
    How are you guys handling field validation? I tried nexus-validate, but getting some type errors. Not 100% sure if it works with the last nexus version.
    r
    • 2
    • 4
  • j

    Josef Henryson

    10/25/2021, 9:03 AM
    I have a problem when trying to use extendType from Nexus. I add a field with a resolver that complains that the type from .prisma/client do not match the nexus type. Nexus expects a field ‘user’ but Prisma only has ‘userId’. Have anyone else had similar problems?
  • a

    Akshay Kadam (A2K)

    10/26/2021, 12:58 PM
    I am unable to create
    schema.graphql
    file when using
    prisma
    +
    nexus-prisma
    → (https://github.com/prisma/nexus-prisma) & thus unable to generate GraphQL Codegen (i tried this on my working setup that deleting
    schema.graphql
    throws the same error) It throws the following error:
    Failed to load schema from ./server/graphql/schema.graphql:
    My
    codegen.yml
    looks like:
    Copy code
    schema: ./server/graphql/schema.graphql
    documents:
      - '**/*.graphql'
      - '!/server/graphql/schema.graphql'
    generates:
      /client/graphql/types.generated.ts:
        plugins:
          - typescript
      ./:
        preset: near-operation-file
        presetConfig:
          baseTypesPath: /client/graphql/types.generated.ts
        plugins:
          - typescript-operations
          - typescript-urql
    And my
    server/graphql/schema.ts
    looks like:
    Copy code
    import { makeSchema } from 'nexus'
    import path from 'path'
    
    import User from './User'
    
    const shouldGenerateArtifacts =
      process.env.NODE_ENV === 'development' || !!process.env.GENERATE
    
    export const schema = makeSchema({
      types: [User],
      plugins: [],
      // Type the GraphQL context when used in Nexus resolvers
      contextType: {
        module: path.join(process.cwd(), 'pages/api/index.ts'),
        export: 'GraphQLContext',
      },
      // Generate the files
      shouldGenerateArtifacts,
      outputs: {
        typegen: path.join(
          process.cwd(),
          'server/graphql/nexus-types.generated.ts'
        ),
        schema: path.join(process.cwd(), 'server/graphql/schema.graphql'),
      },
    })
    How do I make sure it creates
    server/graphql/schema.graphql
    before graphql-codegen runs? Repro is available on
    prisma
    branch → https://github.com/deadcoder0904/twitter-api-v2-3-legged-login-using-next-connect/tree/prisma
    r
    • 2
    • 3
  • j

    Josef Henryson

    11/01/2021, 2:33 PM
    Does anyone know why nexus expects update mutations to have name: { set: $name } instead of just name: $name? In my client I make all calls with the latter format but since upgrading my server API it wants the set: format. Is it configurable?
  • m

    Matheus Assis

    11/05/2021, 2:30 PM
    Is there a way to create a new type, that's extended from another type, but with a new name? I don't want to use
    extendType
    since it modifies the original type (similar to inheritance on OOP)
  • j

    Josef Henryson

    11/15/2021, 12:15 PM
    Any ideas on how to make the ‘json’ field work with Nexus?
    m
    d
    • 3
    • 10
  • s

    Samson Ssali

    11/15/2021, 4:47 PM
    Hello. How do I fix this:
    Copy code
    Cannot read properties of undefined (reading 'engineType')
    I get it when I run
    npm generate
    My nexus - prisma set up failed with this error:
    Copy code
    Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.
    That's why I tried
    npm generate
    r
    • 2
    • 7
  • k

    Kelly Copley

    11/16/2021, 6:48 PM
    Can anyone think of any reason why my vercel build would fail with this error?
    Copy code
    ./graphql/types/division.ts:14:15
    Type error: Property 'dateTime' does not exist on type 'Omit<InputDefinitionBlock<"DivisionInput">, "nonNull" | "nullable">'.
    r
    • 2
    • 4
  • k

    Kelly Copley

    11/17/2021, 2:59 AM
    Turns out this error happens because Nexus generates the types at runtime and I needed to commit the generated types to my repo so that Vercel had access to them during the build process.
    👍 1
  • a

    Awey

    11/18/2021, 10:46 AM
    How does Graphql-Nexus compare to GiraphQL?
  • a

    Awey

    11/25/2021, 3:28 PM
    What options are available for validating inputs?
    h
    r
    • 3
    • 3
  • a

    Anton Pokhylenko

    11/27/2021, 11:34 AM
    hello. I am trying to upgrade old project setup with prisma v2.0.0-beta.5 and nexus-prisma plugin to current version of prisma 3.5.0 and new nexus-prisma so far I am trying to do as described here https://nexus.prisma.io/usage but keep getting error shown on screenshot
    nexus-prisma: not found
    node version is 16.13.0 I've also tried with prisma client version 2.30.0 and got same error what am I missing here?
1...2122232425Latest