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

    Joël

    12/15/2020, 8:56 AM
    https://twitter.com/nexusgql/status/1338584243346214913
  • j

    Joël

    12/15/2020, 8:57 AM
    https://twitter.com/nexusgql/status/1338557643632283649
  • d

    Daniell

    12/15/2020, 2:34 PM
    @Dominic Hadfield I liked your way of structuring the types in the backend, it feels like a infinite scale structure, may I ask if you do the same in the frontend with graphql-codegen? I'm not sure if a root query and mutation folder would be a better choice or Entity/query and Entity/mutation
    d
    • 2
    • 17
  • c

    Curio

    12/15/2020, 3:18 PM
    Is there a way to name a set of custom resolvers for easy finding in GraphQL? For example I have this, which currently works fine.
    Copy code
    export const DashboardQuery = extendType({
      type: 'Query',
      definition(t) {
        // counts
        t.int('countUsers', {
          resolve(_parent, args, ctx) {
            return ctx.prisma.user.count({where: {active: {equals: false}}})
          },
        })
        t.int('countPosts', {
          resolve(_parent, args, ctx) {
            return ctx.prisma.post.count({where: {active: {equals: false}}})
          },
        })
      },
    })
    And i would like this to have it like this in the graphql server?
    Copy code
    counts {
      countUsers
      countPosts
    }
  • d

    Darryl

    12/16/2020, 10:58 AM
    Regarding Nexus 1.0, is
    typegenAutoConfig
    no longer needed/supported in
    makeSchema
    ? I just migrated my project and noticed:
    Copy code
    'typegenAutoConfig' does not exist in type 'SchemaConfig'
    It's also no longer in the docs. Maybe I've missed something but I didn't see anything saying it should be removed so I just wanted to check here. Thanks.
    r
    c
    w
    • 4
    • 5
  • d

    Dickson

    12/17/2020, 8:53 AM
    btw anyone got examples for load testing nexus with prisma (on traditional environment / serverless)?
    r
    • 2
    • 1
  • n

    Nitgo

    12/17/2020, 5:42 PM
    Am following this guide https://dev.to/prisma/complete-introduction-to-fullstack-type-safe-graphql-feat-next-js-nexus-prisma-c5 everything works fine althoough this fat TS error is bothering me how do I make it go away?
    Copy code
    (property) Options.experimentalCRUD?: boolean | undefined
    Enable experimental CRUD capabilities. Add a t.crud method in your definition block to generate CRUD resolvers in your Query and Mutation GraphQL Object Type.
    @default
    false
    Type 'import("/Users/soft_orca/fulls-projects/complete-intro-typesafe-graphql/node_modules/nexus/dist/plugin").NexusPlugin' is not assignable to type 'import("/Users/soft_orca/fulls-projects/complete-intro-typesafe-graphql/node_modules/@nexus/schema/dist/plugin").NexusPlugin'.
      The types of 'config.fieldDefTypes' are incompatible between these types.
        Type 'string | import("/Users/soft_orca/fulls-projects/complete-intro-typesafe-graphql/node_modules/nexus/dist/utils").PrintedGenTypingImport | import("/Users/soft_orca/fulls-projects/complete-intro-typesafe-graphql/node_modules/nexus/dist/utils").PrintedGenTyping | import("/Users/soft_orca/fulls-projects/complete-intro-t...' is not assignable to type 'string | import("/Users/soft_orca/fulls-projects/complete-intro-typesafe-graphql/node_modules/@nexus/schema/dist/utils").PrintedGenTypingImport | import("/Users/soft_orca/fulls-projects/complete-intro-typesafe-graphql/node_modules/@nexus/schema/dist/utils").PrintedGenTyping | import("/Users/soft_orca/fulls-projects/...'.
          Type 'PrintedGenTyping' is not assignable to type 'string | PrintedGenTypingImport | PrintedGenTyping | StringLike[] | undefined'.
            Type 'import("/Users/soft_orca/fulls-projects/complete-intro-typesafe-graphql/node_modules/nexus/dist/utils").PrintedGenTyping' is not assignable to type 'import("/Users/soft_orca/fulls-projects/complete-intro-typesafe-graphql/node_modules/@nexus/schema/dist/utils").PrintedGenTyping'.
              Property 'config' is protected but type 'PrintedGenTyping' is not a class derived from 'PrintedGenTyping'.ts(2322)
    s
    r
    • 3
    • 3
  • t

    Thomas Ladd

    12/18/2020, 12:51 AM
    Using nexus, prisma, nexus-plugin-prisma and upgrading to the latest versions. Previously, I was using
    backingTypes
    so that the DateTime scalar had type
    Date
    in NexusGenScalars. It looks like that option is gone now so I end up with a
    NexusGenScalars
    where DateTime maps to
    any
    .
    Copy code
    export interface NexusGenScalars {
      String: string;
      Int: number;
      Float: number;
      Boolean: boolean;
      ID: string;
      DateTime: any;
    }
    Is there a new way to get a more specific type here for
    DateTime
    ?
    c
    • 2
    • 3
  • c

    Chris Kjær

    12/18/2020, 8:37 AM
    I'm using nexus-prisma-plugin and I'm trying to add a custom resolver for all
    id
    fields. I thought that I could add a resolver for the
    ID
    or
    UUID
    scalar but just realised that all ids are resolved to Int/String. I thought that they would be resolved to the scalars mentioned here https://nexusjs.org/docs/plugins/prisma/api#scalar
    r
    • 2
    • 17
  • d

    Daniell

    12/18/2020, 5:23 PM
    How do you guys handle passwordless auth? What packages do you use?
  • a

    Adam

    12/18/2020, 10:19 PM
    Is there anyway to turn off
    create
    and
    connectOrCreate
    when
    connecting
    an entity to another? Specifically for the generated
    InputTypes
    for graphql?
    r
    • 2
    • 2
  • s

    Stefan Trivuncic

    12/19/2020, 3:29 PM
    Does anyone have any recommendations for folder structure when using React Native? Would it be similar to the Prisma examples when using NextJS ?
  • e

    Eric Reis

    12/19/2020, 3:49 PM
    why does queryField also take a function as second argument? it doesnt seems to be documented
    Copy code
    export const products = queryField('products', () => ({
      type: 'products',
      resolve: async (_, args, { pg, checkAuth }) => {
        await checkAuth();
    
        return findProducts(pg, args);
      },
    }));
  • e

    Eric Reis

    12/19/2020, 3:49 PM
    the function doesnt take any arguments either
  • a

    Adam

    12/21/2020, 7:50 PM
    I'm getting the error
    ERROR: @nexus/schema must be installed as a dependency. Please run npm install @nexus/schema
    after replacing
    @nexus/schema
    with
    nexus
    I saw that
    @nexus/schema
    was renamed to
    nexus
    so I brought that into my project as a direct replacement for
    @nexus/schema
    my
    makeSchema
    config now has the syntax error
    'typegenAutoConfig' does not exist in type 'SchemaConfig'.ts
    and when I try and run it ignoring this error it yells at me to install
    @nexus/schema
    I'm running
    @prisma/cli@2.13.0
    @prisma/client@2.13.0
    nexus-plugin-prisma@0.25.0
    and
    nexus@1.0.0
    I noticed the docs on prisma just show this as importing some 'types' file and the link to the repo shows a 404 https://nexusjs.org/docs/plugins/prisma/overview
    Copy code
    return makeSchema({
        typegenAutoConfig: {
          sources: [
            {
              source: '@prisma/client',
              alias: 'prisma',
            },
            {
              source: require.resolve('./context'),
              alias: 'ContextModule',
            },
          ],
          contextType: 'ContextModule.Context',
        },
        outputs: {
    r
    • 2
    • 8
  • j

    John Smeeth

    12/22/2020, 8:54 AM
    hi all
  • j

    John Smeeth

    12/22/2020, 8:57 AM
    I'm trying to create an explicit many-to-many in prisma by following this link https://www.prisma.io/docs/concepts/components/prisma-schema/relations#many-to-many-relations then using https://github.com/graphql-nexus/nexus-plugin-prisma to generate graphql schema. But when i build (
    "build": "npm -s run clean && npm -s run generate && tsc"
    ) I got error as this
    Copy code
    src/generated/nexus.ts:1324:26 - error TS2339: Property 'CategoriesOnPostsUpdateManyMutationInput' does not exist on type 'NexusGenInputs'.
  • j

    John Smeeth

    12/22/2020, 8:58 AM
    What wrong with me?
  • j

    John Smeeth

    12/22/2020, 8:58 AM
    Copy code
    "nexus": "^1.0.0",
        "nexus-plugin-prisma": "^0.27.0",
        "@prisma/client": "^2.13.0",
    r
    j
    • 3
    • 3
  • v

    Victor

    12/22/2020, 4:58 PM
    👋 Hey guys. I have a question, I need to do some calculations and pass this data to the child resolver. Is it considered "good practice" to solve this problem by mutating the Context object in the parent resolver with the help of
    originalResolve
    as mentioned in this example here? My code would look like this:
    Copy code
    export const UserPortfolioVersion = objectType({
        name: "UserPortfolioVersion",
        definition(t) {
          t.model.id();
          t.model.UserPortfolioInstrument({
            resolve: async (root, args, ctx, info, originalResolve) => {
              // mutate the context
              ctx.metadata = {
                totalValue: 10000, // I need to be able to access this number in the child resolver
              };
              const res = await originalResolve(root, args, ctx, info);
              return res;
            },
          });
        },
    });
    s
    r
    • 3
    • 5
  • t

    Tyson

    12/23/2020, 11:48 PM
    Hey all, I have a question about how to correctly set up scalars (i’m moving off of the nexus framework onto nexus + apollo server). Any ideas? https://github.com/graphql-nexus/nexus-plugin-prisma/issues/1007
    a
    r
    • 3
    • 33
  • j

    John Smeeth

    12/27/2020, 11:46 AM
    hi all, anybody please advise me how to upload file with nexus, single file and multiple file. thank you
  • a

    Adam

    12/29/2020, 5:53 PM
    Can you prevent updates to a field of a model? For example if I have a
    User
    with a
    Role
    field that is text, can I block that from ever being updated thru
    grapql
    ?
  • s

    Stefan N

    12/30/2020, 10:25 AM
    Hey all. Is it correct, that types from nexus-plugin-prisma are generated on each and every request when running with NODE_ENV=development? From my schema.ts:
    Copy code
    plugins: [
        nexusPrisma({
          ...
          shouldGenerateArtifacts: process.env.NODE_ENV === "development",
          ...
        }),
      ],
    I'm running this on next.js with Fast Refresh enabled. The newly generated artifacts will in turn will let next.js think it will need to hot reload. And lastly since a while on each hot reload prisma is starting a new connection pool. So after a few hours of development there are too many active connections on postgres. Not sure where things start to go wrong 🤷‍♂️
  • c

    Can Rozanes

    12/30/2020, 3:21 PM
    what is the best way to handle DateTime type from Prisma in nexus? I have a use case that i assume is pretty common: a User model with
    createdAt
    and
    updatedAt
    fields. When I declare a type associated with this on nexus ie:
    Copy code
    export const User = objectType({
      name: "User",
      definition(t) {
        <http://t.nonNull.int|t.nonNull.int>("id");
        t.nonNull.string("name");
        t.nonNull.string("email");
        t.nonNull.string("createdAt");
        t.nonNull.string("updatedAt");
      },
    });
    I end up getting type error in user resolvers:
    Copy code
    Type 'Date' is not assignable to type 'string'
    j
    • 2
    • 8
  • s

    slinden

    01/01/2021, 9:55 PM
    I am having hard time defining
    contextType
    for the nexus schema. I posted a question in Stack Overflow. It's probably easy to fix, but I just dont see it or dont have the knowledge to solve the problem. https://stackoverflow.com/questions/65532634/correct-way-to-define-contexttype-in-nexusjs-while-using-nextjs
    m
    • 2
    • 4
  • s

    slinden

    01/01/2021, 9:55 PM
    If someone could take a look I would really appreciate it. 🙂
  • m

    Manthan Mallikarjun

    01/02/2021, 1:02 AM
    Anyone having this issue with the nullability guard plugin?
    Unknown type Int provided in nullabilityGuard fallbackValues config.
  • m

    Manthan Mallikarjun

    01/02/2021, 1:02 AM
    Is this because I don't have an Int in my schema?
  • m

    Manthan Mallikarjun

    01/02/2021, 1:02 AM
    I see the same for ID and Float
1...151617...25Latest