-
Notifications
You must be signed in to change notification settings - Fork 860
Generated Prisma client TS typings incompatible with graphqlgen typings for optional fields #3621
Comments
I just found out that this problem also applies to the Flow client. This is the Flow error that's thrown:
|
Effect of
|
Excellent work. Hope this gets fixed soon. |
I have exactly the same problem. Maybe something similar could be the solution here? |
@breytex there is already a clean solution identified though please let us know if you identified any flaws! |
@jasonkuhrt do you mean this PR? prisma-labs/graphqlgen#329 Thanks :) |
I think something like this could work:
Anyway, hopefully the issue will be resolved soon. Also better project ci/cd is something that is on the roadmap I think prisma-labs/graphqlgen#87 |
Related to prisma/prisma#3774 (comment) |
Will this issue be solved soon? If i understand, for the the moment we have to add a |
Also looking forward for this fix. Any updates? |
TS seems to fail finding a global TS interface when put in a hidden folder Add "strict: false" to examples until this lands prisma/prisma#3621
TS seems to fail finding a global TS interface when put in a hidden folder Add "strict: false" to examples until this lands prisma/prisma#3621
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 10 days if no further activity occurs. Thank you for your contributions. |
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:
As suggested by @Weakky here, we need to In order to fix this, we need to both fix
prisma-client
andgraphqlgen
to type all nullable input fields asfield?: type | null
.The text was updated successfully, but these errors were encountered: