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

    Andrew Ross

    11/28/2021, 12:11 AM
    how do you configure the NexusGenFeaturesConfig to support more than resolving types? I'd like for it to support
    __typename
    as an abstract strategy in addition to resolving the types
    Copy code
    export type NexusGenFeaturesConfig = {
      abstractTypeStrategies: {
        isTypeOf: false
        resolveType: true
        __typename: false
      }
    }
  • a

    Andrew Ross

    11/28/2021, 4:29 AM
    nevermind, got it 👍 under makeSchema
    Copy code
    features: {
        abstractTypeStrategies: {
          __typename: true,
          resolveType: true
        }
      },
    Wanted to resolve the output __typenames of Objects in a Node Interface Type That said, I would like to weave a remote endpoint's schema with my server so subgraphs if anyone has tips on stitching remote schema with Nextjs + Prisma + Nexus, please let me know I'm building a crm and having the data used by a headless cms available would be đŸ”„
    👍 1
  • r

    rdunk

    12/14/2021, 6:25 PM
    Anyone managed to get contextType to work nicely with
    nexus
    and
    nexus-prisma
    ?
  • r

    rdunk

    12/14/2021, 6:25 PM
    I can’t seem to get the context type definition to work at all
  • r

    rdunk

    12/14/2021, 6:57 PM
    nvm, for some reason
    makeSchema
    wasn’t actually generating outputs, had to explicitly define paths under
    output.typegen
  • d

    Daniell

    12/16/2021, 3:23 PM
    Did you guys ever create a multi-field resolver with prisma + nexus? Would love to see your implementation for when you want to search by either name, description etc through GraphQL
  • m

    Michael Pacheco

    12/17/2021, 4:09 AM
    Hey all! I've been using nexus for a couple months now and I'm running into an issue. I'm using
    extendType
    to build a Mutation type and it seems its generating a separate Query type by default.
    Copy code
    type Query {
      ok: Boolean!
    }
    I haven't explicitly defined a Query type and it's causing a conflict in my federated schema. I was wondering if there was a way to prevent nexus from generating this default type?
  • r

    Raphael Luckom

    12/17/2021, 4:16 PM
    Hi, I'm investigating upgrading an app from prisma1+prisma-binding to prisma2+(i assume)nexus. The docs for that upgrade (https://www.prisma.io/docs/guides/upgrade-guides/upgrade-from-prisma-1/upgrading-prisma-binding-to-nexus ) suggest that they are out of date because the nexus-prisma library is more current, but the linked library has a warning that it is unready for production use. What's the latest guidance on what to upgrade
    prisma-binding
    to?
    m
    w
    d
    • 4
    • 10
  • d

    Daniell

    01/12/2022, 11:42 AM
    What are your thoughts on nexus auth plugin vs graphql-shield?
  • d

    Damian M

    01/13/2022, 8:05 AM
    Hey, sorry if this is a noob question but is there anyway to infer types or fields when writing your schema with nexus from the schema.prisma file?
  • c

    Charlie Peden

    01/21/2022, 12:22 AM
    Hey folks, a question about calculated types: I have a type with a calculated field:
    Copy code
    const CalculatedOrgUser = objectType( {
    	name: 'CalculatedOrgUser',
    	definition( t ) {
    		t.nonNull.boolean( 'isAdmin', {
    			async resolve( { id }, _, ctx ) {
    				// if there's no orgUser id, then this is moot
    				if ( !id ) {
    					return false;
    				}
    				// return fields we need from an orgUser
    				const returnFields = graphqlSelection( `{
    						id
    						organization {
    						adminUsers { id }
    					}
    				}` );
    				const orgUser = await ctx.prisma.orgUser.findFirst( {
    					where: { id },
    					...returnFields,
    				} );
    				// are they an admin?
    				if (
    					orgUser &&
    					orgUser.organization &&
    					orgUser.organization.adminUsers &&
    					orgUser.organization.adminUsers.length
    				) {
    					return orgUser.organization.adminUsers.some( ( { id: orgUserID } ) => orgUserID === id );
    				}
    				console.log( "pork" );
    				// clearly not
    				return false;
    			}, 
    		} );
    		t.field( 'organization', { type: Organization } );
            /// sundry other fields
    	},
    } );
    however, in the resolver for the query, the calculated field is still being passed in the
    info
    object if queried for. I can prune that out in the resolver, but it seems hacky and I'm sure I'm missing something. Is there something awry in this definition? I've see reference to a
    sourceType
    here https://nexusjs.org/docs/guides/source-types#locally-configure-source-types but I'm not sure I'm barking up the wrong tree. Any advice?
    a
    w
    • 3
    • 23
  • b

    Björnstjerne Tiedemann

    01/27/2022, 4:42 PM
    Hello, is it possible to extend an enumType? I have features for some projects and need to add a member if a feature is available for this API.
    u
    • 2
    • 1
  • w

    Wade McDaniel

    02/18/2022, 9:37 PM
    Here's a weird one: I've defined an arg to a queryType field as having a type of a nullable type of a non-empty array like so
    Copy code
    orderBy: arg( { type: list( nonNull( DocumentOrderByInput ) ) } ),
    The problem is that I can pass
    orderBy: { createdAt: desc }
    without error! In the resolver I see
    orderBy: [{ createdAt: desc }]
    regardless of if I use an array or an object in the GraphQL query. 1. Shouldn't I get an error when orderBy is referenced like it was an object? 2. And why does
    list()
    convert the object to an array: is that the way it's supposed to behave? Thanks!
  • d

    Denise Gurer

    03/01/2022, 4:53 AM
    Hello. I just transitioned to Nexus and am following the Nexus tutorial. In the last chapter there is a __helpers.ts file which defines a function: prismaTestContext(). In that function a sqlite database is created and then closed for each schema. There are two lines of code: const client = new Database('memory'); await client.close(); I'm using a mysql database and was wondering what I should replace these two lines with for mysql. I've installed node-mysql2 but can't find the equivalent functionality. I'd appreciate any help. Thanks! Note: the tutorial I'm following is at https://nexusjs.org/docs/getting-started/tutorial/chapter-testing-with-prisma
    u
    • 2
    • 2
  • j

    Jonas Rothmann

    03/07/2022, 9:19 AM
    is there a soft limit of 1000 requests in nexus-prisma? If I pull 999 requests all my relations are filled, 1000 and they are null
    • 1
    • 1
  • y

    YeonHoPark

    03/07/2022, 2:40 PM
    Hi !! Doesn’t nexus support custom directive ?
    u
    • 2
    • 1
  • b

    Brannon

    03/09/2022, 11:51 PM
    I've defined a field with Decimal type in my prisma schema. What should I use for the type in nexus?
  • b

    Brannon

    03/09/2022, 11:59 PM
    In the prisma schema:
    orderAmount       Decimal
  • b

    Brannon

    03/10/2022, 12:00 AM
    there is no
    t.decimal
    though (for example:
    <http://t.nonNull.int|t.nonNull.int>('orderId')
    )
    a
    • 2
    • 5
  • j

    Jonathan

    03/15/2022, 8:23 PM
    Does anyone have a good way of counting the number of
    prisma queries
    and collecting how many are run per resolver? I want to add a Nexus plugin that can count them, but I worry due to the async nature of it all, storing queries on a
    global
    object will simply be too buggy
    w
    y
    • 3
    • 3
  • k

    Kelly Copley

    03/20/2022, 4:39 PM
    Does anyone have a working example of using Nexus with graphql-codegen to generate apollo query hooks?
    n
    • 2
    • 1
  • j

    James Kienle

    03/30/2022, 2:52 AM
    Hey all! Question on the
    nexus-prisma
    module. I have the following model in
    schema.prisma
    Copy code
    model Product {
      id String @id @default(uuid())
      createdAt DateTime @default(now())
      updatedAt DateTime @updatedAt
      category String @db.VarChar(64)
      description String @db.Text
      images String[] @db.VarChar(255)
      name String @db.VarChar(64)
      packageHeight Float
      packageLength Float
      packageWidth Float
      price Int
      quantity Int
      shortDescription String @db.VarChar(255)
    }
    Inside of my schema, I have the following Nexus object
    Copy code
    import { objectType } from 'nexus';
    import { Product } from 'nexus-prisma';
    
    export const product = objectType({
      name: Product.$name,
      description: Product.$description,
      definition: (t) => {
        t.field(Product.id);
        t.field(Product.name);
        t.field(Product.category);
        t.field(Product.description);
        t.field(Product.images);
        t.field(Product.name);
        t.field(Product.price);
        t.field(Product.quantity);
        t.field(Product.shortDescription);
      },
    });
    Is there a way to automatically populate those fields in the object? I'd love to not have to repeat myself as much in my code where possible
    🙌 1
    w
    • 2
    • 1
  • a

    Aniket Chavan

    04/04/2022, 2:59 PM
    I can only assume this question has been asked a million times so I apologise in advance but it is the sole reason I'm here 😅 Is federation support coming to nexus any time soon? I'm currently trying to build out a backend which I want to split into microservices with a federated graph. Currently I'm using typescript + prisma + typegraphql + apollo server. The major issue I've been finding is how to handle both the data API as well as the backend API. I see both nexus and tgql offer tools to generate a code-first gql schema based on a prisma schema, but I don't know how to mark certain fields with @extends decorators for example if the type definitions are largely generated from the prisma schema.
    e
    • 2
    • 1
  • u

    Ulisses Cruz

    04/05/2022, 9:28 AM
    Hello, is it possible to autogenerate the prisma input filters to the graphql SDL?
  • y

    YeonHoPark

    04/06/2022, 10:01 AM
    Hi. why isn’t age defined in the User type of NexusGenObjects(i know that NexusGenObjects is the “root” type) ? the difference between the age field and other field’s is that the age field implements a resolver directly. In the picture of the official document below, the field that implements the resolver is also defined in the type.
    Copy code
    type User {
      age: String
      fullName: String
      name: String
    }
    j
    h
    w
    • 4
    • 8
  • e

    Erik

    04/11/2022, 2:32 PM
    i have a problem with the code below: running the mutation
    deleteOneTournament
    and querying the "teams" field results in an error:
    Cannot return null for non-nullable field Tournament.teams.
    .
    prisma.tournament.delete
    does return an array with `Team`s, am I doing something wrong?
    stuff_ts.ts
    • 1
    • 1
  • j

    John Smeeth

    04/12/2022, 2:55 PM
    hi all, I'm using prisma and nexus. I have a prisma model as below
    Copy code
    model ServiceProject {
      id                   String                @id @default(cuid())
      createdAt            DateTime              @default(now())
      updatedAt            DateTime              @updatedAt
      name                 String
      thumbnailUrl         String?               @map("thumbnail_url")
      displayOnServicePage Boolean               @default(true) @map("display_on_service_page")
      serviceId            String
      Service              Service               @relation(fields: [serviceId], references: [id])
      ServiceProjectImage  ServiceProjectImage[]
    
      @@map("service_project")
    }
    And after run
    prisma generate
    I got these
    Copy code
    export type ServiceProjectCreateInput = {
        id?: string
        createdAt?: Date | string
        updatedAt?: Date | string
        name: string
        thumbnailUrl?: string | null
        displayOnServicePage?: boolean
        Service: ServiceCreateNestedOneWithoutServiceProjectInput
        ServiceProjectImage?: ServiceProjectImageCreateNestedManyWithoutServiceProjectInput
      }
    
      export type ServiceProjectUncheckedCreateInput = {
        id?: string
        createdAt?: Date | string
        updatedAt?: Date | string
        name: string
        thumbnailUrl?: string | null
        displayOnServicePage?: boolean
        serviceId: string
        ServiceProjectImage?: ServiceProjectImageUncheckedCreateNestedManyWithoutServiceProjectInput
      }
    I also define an inputObjectType via nexus as below
    Copy code
    export const ServiceProjectCreateInput = inputObjectType({
      name: 'ServiceProjectCreateInput',
      definition(t) {
        t.nonNull.string('name')
        t.string('thumbnailUrl')
        t.nonNull.boolean('displayOnServicePage')
        t.nonNull.string('serviceId')
      },
    })
    This is mutation
    Copy code
    export const createServiceProject = mutationField('createServiceProject', {
      type: 'ServiceProject',
      args: {
        data: arg({ type: 'ServiceProjectCreateInput' }),
      },
      resolve: async (_parent, { data }, context: Context) => {
        return context.prisma.serviceProject.create({
          data,
        })
      },
    })
    I got this error
    Copy code
    Type '{ displayOnServicePage: boolean; name: string; serviceId: string; thumbnailUrl?: string | null | undefined; } | null | undefined' is not assignable to type '(Without<ServiceProjectCreateInput, ServiceProjectUncheckedCreateInput> & ServiceProjectUncheckedCreateInput) | (Without<...> & ServiceProjectCreateInput)'.
      Type 'undefined' is not assignable to type '(Without<ServiceProjectCreateInput, ServiceProjectUncheckedCreateInput> & ServiceProjectUncheckedCreateInput) | (Without<...> & ServiceProjectCreateInput)'.ts(2322)
    index.d.ts(5331, 5): The expected type comes from property 'data' which is declared here on type '{ select?: ServiceProjectSelect | null | undefined; include?: ServiceProjectInclude | null | undefined; data: (Without<ServiceProjectCreateInput, ServiceProjectUncheckedCreateInput> & ServiceProjectUncheckedCreateInput) | (Without<...> & ServiceProjectCreateInput); }'
    ServiceCreateInput
    What wrong with me? Can anybody give me an advise? thank you
    e
    • 2
    • 1
  • j

    John Smeeth

    04/12/2022, 2:56 PM
    More information, this is type generated by nexus
    Copy code
    ServiceProject: { // root type
        displayOnServicePage?: boolean | null; // Boolean
        id?: string | null; // String
        name?: string | null; // String
        serviceId?: string | null; // String
        thumbnailUrl?: string | null; // String
      }
  • m

    Martin Pinnau

    05/09/2022, 2:44 PM
    Hi, is there an updated version of this upgrade guide available ? https://www.prisma.io/docs/guides/upgrade-guides/upgrade-from-prisma-1/upgrading-nexus-prisma-to-nexus
    n
    n
    • 3
    • 4
  • m

    Martin Pinnau

    05/09/2022, 2:46 PM
    It still uses
    nexus-plugin-prisma
    , I already removed it and installed
    nexus-prisma
    missing the corresponding steps for upgrade 😉
1...2122232425Latest