-
Notifications
You must be signed in to change notification settings - Fork 5
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
GraphQL queries fail if the input contains any unknown fields #140
Comments
I did a bit of research on this and it looks like there's an open issue for this kind of thing in TypeScript already. There are a few suggested workarounds, I think my favorite of which is microsoft/TypeScript#12936 (comment), but after tinkering with our code a bit it looks like it would require a fair amount of refactoring to support. Yet another solution might actually be to modify our GraphQL server to simply ignore unrecognized input fields rather than throwing; however, if it's standard behavior for a GraphQL server to error when this happens, instead of merely a Graphene-specific idiosyncrasy, I'd prefer to avoid this solution. |
Working on #213, I added a |
I've mitigated this in #217 with a helper function but I'm going to leave this issue open as a low-priority one because it'd still be nice to not have to remember to use the helper. |
While working on #139, I ran into a runtime error because I was passing a query to GraphQL that included a superset of the required input. TypeScript doesn't normally care about this, which is why it didn't complain, but the GraphQL server did care. It would be nice to solve this somehow at the type-checking level, e.g. perhaps there's an
Exact<T>
mapped type that makes sure that any fields not inT
arenever
or something.Barring that, we could add code to the queryfetcher that explicitly picks only the keys it needs from the input, but that will add code bloat and also might be non-trivial since I don't think queryfetcher actually understands anything about the structure of its inputs.
The text was updated successfully, but these errors were encountered: