Repository navigation
3.3.0: fragment masking and persisted documents - #17
Merged
Merged
Conversation
A spread becomes one member holding the fragment's data, parsed from the same JSON object; toJson merges it back. Conditional spreads and fragments of other packages stay unmasked. Also reads the persisted_documents option.
Ids hash the text package:graphql sends (gql() adds root __typename). PersistedDocumentsSerializer sends the id as extensions.persistedQuery, documentId or id; directory: writes <id>.graphql files for Hot Chocolate.
…l server The apollo format works with its SHA-256 hex provider, id with any; documentId isn't read, and a document next to an id is refused when only persisted documents are allowed. Moves a prune_types note back.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two opt-in options, both off by default.
fragment_masking
A spread fragment's fields stay off the class that spreads it; the class gets one member with the fragment's data instead (
me.userCard.avatarUrl). The member is parsed from the same JSON object andtoJson()merges it back, so cache writes stay complete. Fragments mask the fragments they spread. Spreads under@skip/@includeand fragments fromfragment_importsstay unmasked.persisted_documents
Every operation document gets an id (sha256 by default, or sha1/md5) and a JSON manifest maps ids to documents;
directory:also writes<id>.graphqlfiles (Hot Chocolate's file system storage).PersistedDocumentsSerializerforHttpLinksends the id asextensions.persistedQuery,documentIdorid. The id hashes the textpackage:graphqlactually sends:gql()adds a root__typename, which a first version missed.Tests
GraphQLClientand its cache; persisted documents against a local HTTP server that only knows the manifest, in all three formats.idand by the Apollo format (with the SHA-256 hex provider) run; text documents are refused. README describes the server setup.