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

(graphcache) - Add root operation type traversal warning #859

Merged
merged 4 commits into from
Jun 12, 2020

Conversation

kitten
Copy link
Member

@kitten kitten commented Jun 12, 2020

Resolve #858

Summary

Add warning for queries that traverse an Operation Root Type (Mutation / Subscription types occuring in a query result)

It's possible for someone to explicitly use Mutation or Subscription inside Query, which by convention is discouraged and shouldn't be done. The worst that we do in such a case is now issue a warning, but I believe it's more important to prevent this mistake than to ignore it silentily, especially since it's extremely uncommon.

Set of changes

  • Add check to readSelection for non-Query root types and issue warning
  • Add explanation of the warning to errors.md
  • Ensure that the warning logs out the relevant typenames

@changeset-bot
Copy link

changeset-bot bot commented Jun 12, 2020

🦋 Changeset is good to go

Latest commit: 466623b

We got this.

This PR includes changesets to release 1 package
Name Type
@urql/exchange-graphcache Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kitten kitten changed the title Fix/add root traversal warning (graphcache) Add root operation type traversal warning Jun 12, 2020
@kitten kitten changed the title (graphcache) Add root operation type traversal warning (graphcache) - Add root operation type traversal warning Jun 12, 2020
Copy link
Collaborator

@JoviDeCroock JoviDeCroock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, great one!

Copy link
Contributor

@amyboyd amyboyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Nice one.

docs/graphcache/errors.md Outdated Show resolved Hide resolved
exchanges/graphcache/src/operations/query.ts Outdated Show resolved Hide resolved
@kitten kitten merged commit 0a90257 into master Jun 12, 2020
@kitten kitten deleted the fix/add-root-traversal-warning branch June 12, 2020 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected data: null in useQuery result, possibly due to __typename: 'Subscription'
3 participants