You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 8, 2021. It is now read-only.
When using the Prisma client together with graphqlgen in TS scrict mode, the generated typings for optional fields from the Prisma datamodel and the graphqlgen resolver arguments don't match. Example:
The content field is optional in the createDraft mutation. Now, the generated resolver args from graphqlgen for the input to createDraft look like this:
content here is declared as an optional instead of string | null. As fas as I understand, the optional is interpreted as string | undefined. Now, when implementing the createDraft resolver like so:
src/resolvers/Mutation.ts:15:7 - error TS2322: Type 'string | null' is not assignable to type 'string | undefined'.
Type 'null' is not assignable to type 'string | undefined'.
15 content,
~~~~~~~
src/generated/prisma-client/index.ts:282:3
282 content?: String;
~~~~~~~
The expected type comes from property 'content' which is declared here on type 'PostCreateInput'
src/resolvers/Query.ts:14:29 - error TS2345: Argument of type '{ where: { OR: ({ title_contains: string | null; } | { content_contains: string | null; })[]; }; }' is not assignable to parameter of type '{ where?: PostWhereInput | undefined; orderBy?: "id_ASC" | "id_DESC" | "createdAt_ASC" | "createdAt_DESC" |"updatedAt_ASC" | "updatedAt_DESC" | "published_ASC" | "published_DESC" | ... 4 more ... | undefined; ... 4 more ...; last?: number | undefined; }'.
Types of property 'where' are incompatible.
Type '{ OR: ({ title_contains: string | null; } | { content_contains: string | null; })[]; }' is not assignable to type 'PostWhereInput'.
Types of property 'OR' are incompatible.
Type '({ title_contains: string | null; } | { content_contains: string | null; })[]' is not assignable to type 'PostWhereInput | PostWhereInput[] | undefined'.
Type '({ title_contains: string | null; } | { content_contains: string | null; })[]' is not assignable to type 'PostWhereInput[]'.
Type '{ title_contains: string | null; } | { content_contains: string | null; }' is not assignable to type 'PostWhereInput'.
Type '{ title_contains: string | null; }' is not assignable to type 'PostWhereInput'.
Types of property 'title_contains' are incompatible.
Type 'string | null' is not assignable to type 'string | undefined'.
Type 'null' is not assignable to type 'string | undefined'.
14 return ctx.prisma.posts({
~
15 where: {
~~~~~~~~~~~~~~
...
24 },
~~~~~~~~
25 })
~~~~~
The text was updated successfully, but these errors were encountered:
When using the Prisma client together with
graphqlgen
in TS scrict mode, the generated typings for optional fields from the Prisma datamodel and thegraphqlgen
resolver arguments don't match. Example:datamodel.prisma
For example,
content
onPost
is optional here. Now consider this GraphQL schema:The
content
field is optional in thecreateDraft
mutation. Now, the generated resolver args fromgraphqlgen
for the input tocreateDraft
look like this:On the other hand, the generated
PostCreateInput
type for thecreatePost
operation in the Prisma client API looks as follows:content
here is declared as an optional instead ofstring | null
. As fas as I understand, the optional is interpreted asstring | undefined
. Now, when implementing thecreateDraft
resolver like so:TypeScript throws this error in strict mode:
The text was updated successfully, but these errors were encountered: