-
Notifications
You must be signed in to change notification settings - Fork 122
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
Fix handling of empty JSON object response and no field selection #248
base: master
Are you sure you want to change the base?
Fix handling of empty JSON object response and no field selection #248
Conversation
@klarstrup: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/ |
@klarstrup looks like there was a failing test at |
@klarstrup various GraphQL schema parsers throw linting or parsing errors when you don't select fields for every type of Query. (We had a workaround/convention of typing such responses I'm not sure I want to merge this if it's supporting an "invalid" variant of the GraphQL language. What are your thoughts? /cc @abrahamcuenca |
I'm not sure I follow @fbartho, this doesn't concern GraphQL parsing at all but rather an occasional scenario where some JSON APIs will respond with an empty object in some cases. This can't exactly be modeled in GraphQL so I reasoned for falling back to Edit: Ah I see now what you mean, it has been a while. But top level fields with no selection set(primitive values) are valid to my recollection. Edit 2: Yeah it's even an example in the docs https://spec.graphql.org/June2018/#example-e2969 |
I agree @fbartho we should avoid any |
Still not following. Every field of |
Background: I have to work against an API where certain
DELETE
requests will respond happily with that empty{}
object, and RestLink asplodes.This PR makes it so that a
{}
200 API response succesfully becomes anull
when no fields have been requested, as there is no such thing as an empty object in GraphQL.Not sure whether this would be considered a bugfix or a new feature, I couldn't find any prior discussion about behavior for this scenario.