Skip to content
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

Throw when querying non-scalar objects without a selection set. #4038

Merged
merged 4 commits into from
Oct 26, 2018

Conversation

benjamn
Copy link
Member

@benjamn benjamn commented Oct 23, 2018

This would have helped diagnose the cause of #4025, which is that query fields with non-scalar types (or list-of-non-scalar types) must have a selection set.

In other words, given a schema like

type Query {
  selectedMessageList: [SelectedMessage]
}

a query like

query getSelectedMessageList {
  selectedMessageList @client
}

is illegal since it doesn't specify which fields of the SelectedMessage objects should be included in the list.

This PR prevents the cache from accidentally returning IdValue objects by throwing a helpful exception:

Missing selection set for object of type SelectedMessage returned for query field selectedMessageList

While the client does not have access to the schema, it is possible to determine if a value that's about to be returned is a non-scalar object.

@jbaxleyiii
Copy link
Contributor

@benjamn could we add a test showing this working?

Otherwise I think this is a great post read notification to help with some gotchas of not having a full schema!

This would have helped diagnose the cause of #4025, which is that query
fields with non-scalar types (or list-of-non-scalar types) must have a
selection set.

In other words, given a schema like

  type Query {
    selectedMessageList: [SelectedMessage]
  }

a query like

  query getSelectedMessageList {
    selectedMessageList @client
  }

is invalid since it doesn't specify which fields of the SelectedMessage
objects should be included in the list.
@benjamn benjamn force-pushed the issue-4025-warn-about-missing-selection-set branch from 523dd2d to 2e70c99 Compare October 26, 2018 17:21
@benjamn benjamn merged commit 256585b into master Oct 26, 2018
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants