We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have
export const Mutation = mutationType({ definition(t) { t.nonNull.field("upsertOneGame", { type: "Game", args: { data: arg({ type: nonNull(GameUpsertInput) }), }, async resolve(_, args, ctx: Context) { return ctx.prisma.game.upsert({ where: { id: args.data.id, }, create: args.data, update: {}, }); }, }); }, }); // ... other inputObjectTypes const GameCreateWithoutTeamsInput = inputObjectType({ name: "GameCreateWithoutTeamsInput", definition(t) { t.string("id"); t.nonNull.string("name"); t.nonNull.field("setting", { type: SettingCreateNestedOneWithoutGameInput, }); }, }); const SettingCreateNestedOneWithoutGameInput = inputObjectType({ name: "SettingCreateNestedOneWithoutGameInput", definition(t) { t.field("connect", { type: WhereUniqueInput }); t.field("connectOrCreate", { type: SettingCreateOrConnectWithoutGameInput, }); t.field("create", { type: nonNull(SettingCreateWithoutGameInput) }); }, }); const SettingCreateOrConnectWithoutGameInput = inputObjectType({ name: "SettingCreateOrConnectWithoutGameInput", definition(t) { t.nonNull.field("create", { type: nonNull(SettingCreateWithoutGameInput) }); t.nonNull.field("where", { type: nonNull(WhereUniqueInput) }); }, }); const SettingCreateWithoutGameInput = inputObjectType({ name: "SettingCreateWithoutGameInput", definition(t) { t.string("id"); t.nonNull.string("map"); t.nonNull.string("mapSize"); t.nonNull.field("timestamp", { type: DateTime }); t.nonNull.int("endTurn"); }, });
based on the Prisma schema of
// ... other models model Game { id String @id @default(uuid()) name String setting Setting @relation(fields: [settingId], references: [id]) teams InGameTeam[] settingId String @unique } model Setting { id String @id @default(uuid()) map String mapSize String timestamp DateTime endTurn Int game Game? }
and generated client of
// ... other types export type SettingCreateWithoutGameInput = { id?: string map: string mapSize: string timestamp: Date | string endTurn: number }
Then shouldn't it be fine without nonNull? Not sure if this is a bug or by the specification though.
nonNull
The text was updated successfully, but these errors were encountered:
This is not a Nexus Prisma issue.
GraphQL does not make a semantic distinction between passing nothing versus passing explicit null in optional fields while Prisma does.
null
There is no good solution to this.
You can do ?? undefined to remove the null.
?? undefined
Sorry, something went wrong.
Thanks for the reply, I'll go with your solution.
It has been asked before in the previous version of nexus-prisma graphql-nexus/nexus-plugin-prisma#863
nexus-prisma
I think reopening this issue should be considered
Maybe this works for some cases apollographql/apollo-client#2412 (comment)
Also worth checking out
But it'd be nice to have a utility that replaces null to undefined when needed
undefined
function replaceUnwantedNullToUndefined<GraphQLArg, PrismaArg>(graphqlArg: GraphQLArg) {}
No branches or pull requests
Screenshot
Description
I have
based on the Prisma schema of
and generated client of
Then shouldn't it be fine without
nonNull
?Not sure if this is a bug or by the specification though.
The text was updated successfully, but these errors were encountered: