-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
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
null instead of undefined #262
Comments
Maybe some day with a flag later. Using nulls make using Zeus extremely painful |
Thanks for your prompt reply 🙌 But isn't it ultimately a caveat of using a GraphQL API? |
They should. It is much easier to manage those objects without nulls. However we can make a config file for zeus to maintain all those flags like nulls vs undefined |
We are using Zeus heavily on our codebase with a patch to use |
@aexol it seems like it's not just me, so can you please elaborate on the "much easier" part of |
ok, if you have an object stored and you want to provide values from the frontend side, then every optional field if the type is inferred by Zeus has to be manually typed as |
@aexol sorry, I don't think I understand why "every optional field if the type is inferred by Zeus has to be manually typed as null"? can't Zeus infer types as |
@aexol for your example, if I need to insert something from the frontend, let's say a user, each field will be optional because Data returned by the API is typed by the |
I will provide an example when I will have time for that |
@aexol do you have any updates please? |
I just ran into an issue because of this. const {x = 1, y = 2} = {x: undefined, y: null};
console.log(x, y); // 1, null
Absolutely not, this feature is breaking type safety. |
@aexol would you accept a PR where we enable this to be configured via a flag? I've been maintaining a fork of v4 for a few months and most changes are now useless thanks to the nice changes of v5. If this can be useful to someone else, here's the commit on our fork to use |
@aexol any updates on this? |
@ValentinH Here is a small update to your diff: you need to update export type MapType<SRC, DST, SCLR extends ScalarDefinition> = SRC extends null
? null
: SRC extends DeepAnify<DST>
? IsInterfaced<SRC, DST, SCLR>
: never; Otherwise, the It would be nice to have this fixed directly in Zeus :) |
Thanks for sharing this. FWIW we have decided to migrate to https://the-guild.dev/graphql/codegen as the Zeus codegen size (more than 200k LOC as of today) was getting way too big for us (and for Next.js, tsc and VSCode 😅). Also being able to author real Graphql is in the end a win as we don't have to teach yet another tech to the team and we can benefit from more tooling. |
I was thinking of making the same move for a while now, but with Houdini taking care of the plumbing. Thanks for your tip! |
Interesting approach! |
done!!!! Nulls are in responses - also enums are standard not const |
You're awesome @aexol, thank you! |
Hello @aexol, thanks for your amazing library.
The generated type for nullable fields in v4.0.4 is
... | undefined
while in reality the runtime type is... | null
.The issue was originally reported in #171 and #184 for v3, it came back and is reproduced in v4.0.4 #171 (comment), likely because of commit a338a8d.
Can you give an update on this? Do you plan to replace
undefined
withnull
? Perhaps, in v5? If no, why?The text was updated successfully, but these errors were encountered: