Andrew Ross
11/28/2021, 12:11 AM__typename
as an abstract strategy in addition to resolving the types
export type NexusGenFeaturesConfig = {
abstractTypeStrategies: {
isTypeOf: false
resolveType: true
__typename: false
}
}
Andrew Ross
11/28/2021, 4:29 AMfeatures: {
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 đ„rdunk
12/14/2021, 6:25 PMnexus
and nexus-prisma
?rdunk
12/14/2021, 6:25 PMrdunk
12/14/2021, 6:57 PMmakeSchema
wasnât actually generating outputs, had to explicitly define paths under output.typegen
Daniell
12/16/2021, 3:23 PMMichael Pacheco
12/17/2021, 4:09 AMextendType
to build a Mutation type and it seems its generating a separate Query type by default.
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?Raphael Luckom
12/17/2021, 4:16 PMprisma-binding
to?Daniell
01/12/2022, 11:42 AMDamian M
01/13/2022, 8:05 AMCharlie Peden
01/21/2022, 12:22 AMconst 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?Björnstjerne Tiedemann
01/27/2022, 4:42 PMWade McDaniel
02/18/2022, 9:37 PMorderBy: 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!Denise Gurer
03/01/2022, 4:53 AMJonas Rothmann
03/07/2022, 9:19 AMYeonHoPark
03/07/2022, 2:40 PMBrannon
03/09/2022, 11:51 PMBrannon
03/09/2022, 11:59 PMorderAmount Decimal
Brannon
03/10/2022, 12:00 AMt.decimal
though (for example: <http://t.nonNull.int|t.nonNull.int>('orderId')
)Jonathan
03/15/2022, 8:23 PMprisma 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 buggyKelly Copley
03/20/2022, 4:39 PMJames Kienle
03/30/2022, 2:52 AMnexus-prisma
module. I have the following model in schema.prisma
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
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 possibleAniket Chavan
04/04/2022, 2:59 PMUlisses Cruz
04/05/2022, 9:28 AMYeonHoPark
04/06/2022, 10:01 AMtype User {
age: String
fullName: String
name: String
}
Erik
04/11/2022, 2:32 PMdeleteOneTournament
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?John Smeeth
04/12/2022, 2:55 PMmodel 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
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
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
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
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 youJohn Smeeth
04/12/2022, 2:56 PMServiceProject: { // root type
displayOnServicePage?: boolean | null; // Boolean
id?: string | null; // String
name?: string | null; // String
serviceId?: string | null; // String
thumbnailUrl?: string | null; // String
}
Martin Pinnau
05/09/2022, 2:44 PMMartin Pinnau
05/09/2022, 2:46 PMnexus-plugin-prisma
, I already removed it and installed nexus-prisma
missing the corresponding steps for upgrade đ