-
Notifications
You must be signed in to change notification settings - Fork 426
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
Support i16 as additional integer type #198
Conversation
Codecov Report
@@ Coverage Diff @@
## master #198 +/- ##
==========================================
+ Coverage 89.88% 89.89% +<.01%
==========================================
Files 96 96
Lines 17442 17468 +26
==========================================
+ Hits 15678 15702 +24
- Misses 1764 1766 +2
Continue to review full report at Codecov.
|
Hmmm, not sure if having two |
I do not see any problem here because this is a thing that happens purely internally. Both types have exact the same representation exposed to clients. The only thing that could go possibly wrong is that someone tries to use a value outside of the valid range for i16, but this could also happen today (If someone tries to use a value outside of i32) That said I think there should also be support for |
Isn't the name "Int" name exposed in the introspection query? I could be turned around here... |
Yes sure, both are exposed as "Int" there, but I do not see any problem with this. To state it somewhat different: For the reading case this will work in every case, because the number is simply returned as number. For the writing case this will work as long as the supplied number is part of the value range of an |
Right, but the spec explicitly says Ints are 32bit: So it would be completely unexpected for a client to provide an Int larger than i16 and get back an error (from the client perspective). |
So if we name that type just |
Ok, after your explanation making it click (thanks!) and thinking about it some more, I don't think this belongs in Juniper. Juniper tries to be 100% spec compliant. In this case, the inbuilt scalars are defined in GraphQL and it wouldn't be correct to add a juniper-specific Int16...that would be juniper-specific extended functionality and may not be what library users expect. And as I said in the comments, merely allowing Int to be i16 isn't great as the spec explicitly says Ints are i32. It would be completely unexpected for a client to provide an Int larger than i16 and get back an error (from the client perspective) and thus Juniper wouldn't really be spec compliant. If this is a large hardship for wundergraph rather than an annoyance it would be good to know to think through alternatives or perhaps add a feature flag to Juniper with this patch. |
For wundergraph the situation is as follows:
So there are possible several solutions here:
That said: I'm on vacation for the next few weeks. Maybe I've a other idea there. Otherwise I will try to do some research on this as soon as I'm back. (I think we are not the first ones with this issue 😉. Someone out there surly needed to use for example 64 bit integers.) |
As promised I've done some research on this.
If I read the spec correctly it is totally OK to define custom scalar types:
And also the following section regarding to 64 bit integers (highlighting by me):
Therefore I suggest the following solution: ping @LegNeato @theduke |
Doing this seems to be safe.
This is useful for mapping database entries of the corresponding type to a graphql schema.