-
Notifications
You must be signed in to change notification settings - Fork 54
Nullable field causing type assignment error #50
Comments
Cause of type error: I will be adding PR to this thread that will change interface to use undefined instead of null. Thx |
Test based on basic schema
|
@divyenduz I think you should research code from https://github.com/dotansimha/graphql-code-generator |
@Jas99 : Can you please share the version of your |
Hey @divyenduz
I don't think one can use types as arguments, doesn't it has to be input type? PS: using 0.2.4 |
Yes, it has to be an input type. This looks like a bug. |
@divyenduz Any Update on this issue ? |
And this issue only happens when having |
@kevinmarrec No that was not the issue. Generated interfaces returns Null but the scaffold is generating undefined type instead of null; which causes type mismatch. |
Oh yeah I got confused 😅, but anyway the error which allowed you to see the issue could only happen with the So the PR is fixing the scaffolding and when we want to do things by ourselves it's about replacing |
@kevinmarrec Right on.. actually for some weird reason @divyenduz intentionally introduced undefined which might not be inline with graphqljs implementation. |
@Jas99 : Thanks! that makes sense, can you please create a minimal reproduction project with In the mean time, can you also please create an issue for the input issue, hopefully with a reproduction 🙏 I will try to get both these resolved ASAP. Thanks! |
@divyenduz Buddy strick mode is true by default which means strickNullCheckts is also true by default and the issue with type-mismatch was not edge case. typescript-graphql-auth in prisma-examples has user with nullable property. If you lint it; you will see the issue. Please re-read the very first comment. I have reattached the pic. PS: My pr #52 fixes this. I will merge PR with recent update from master. Thx |
@Jas99 Removing the cause of |
@Jas99 As far as I know, the problem is : Typescript But in GraphQL Language it means that the field can return a "nullable" so the type needs to be |
@Jas99 @kevinmarrec : Can anyone of you prepare a minimal reproduction repository? Currently, I just have some code + an image. Real code would help 🙏 |
@kevinmarrec I personally use https://www.npmjs.com/package/@jas99/graphql-resolver-codegen |
@divyenduz https://github.com/kevinmarrec/typescript-prisma-minimal
|
@Jas99 On |
And |
@kevinmarrec strictNullChecks is true by default |
@Jas99 Not for me |
@kevinmarrec when you do tsc --init; can you see |
@Jas99 Well in my project I have a custom |
But anyway with |
@Jas99 Maybe thr are new changes; I will look into it. Meanwhile instead of |
@divyenduz I tried locally to replace all Maybe should we replace all |
@kevinmarrec Check conversation at #51 |
@Jas99 Checked but I still don't know what is the problem ? It seems to be a choice by opinion and not a followed directive provided by GraphQL-Js (if i'm wrong please give me some references to read or code to know what's going on between using |
Prisma Client itself generates Model Nodes (UserNode for example) with |
I assume this has been fixed by the latest version. Please open a new issue if this problem still occurs. |
Check #278 |
How do I update a date field to null or undefiend? |
Hey @divyenduz @timsuchanek
Steps to reproduce
Use below schema.graphql and yield fresh interfaces and scaffold.
Following type error is produced
The text was updated successfully, but these errors were encountered: