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

feat: Add support for persisted documents via the documentId property #3515

Merged
merged 3 commits into from
Mar 2, 2024

Conversation

kitten
Copy link
Member

@kitten kitten commented Mar 2, 2024

Summary

This PR adds support for persisted documents, as long as:

  • An input GraphQL AST contains a documentId property
  • A GraphQL API accepts the documentId parameter as a replacement for the query parameter

When we detect the documentId property on a document which has no definitions (either an empty array or not defined), we send a documentId instead of a query.

This is similar to Automatic Persisted Queries (APQs), but those require the @urql/exchange-persisted exchange, to facilitate generating persisted queries on the fly (as per the spec) and retrying them.

This is to comply with: graphql/graphql-over-http#264

Set of changes

  • Add documentId property to detected GraphQL document types
  • Send documentId on FetchBody when a persisted document is passed

Copy link

changeset-bot bot commented Mar 2, 2024

🦋 Changeset detected

Latest commit: 33bf2f3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@urql/core Minor

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
Copy link
Member Author

kitten commented Mar 2, 2024

Merging since it technically doesn't matter when we land this exactly

@kitten kitten merged commit 614c732 into main Mar 2, 2024
13 checks passed
@kitten kitten deleted the feat/persisted-documents branch March 2, 2024 13:13
@github-actions github-actions bot mentioned this pull request Mar 2, 2024
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.

2 participants