Allow optional cacheID on the persisted-id RequestParameters variant - #5383
Open
GregoryCollett wants to merge 1 commit into
Open
Allow optional cacheID on the persisted-id RequestParameters variant#5383GregoryCollett wants to merge 1 commit into
GregoryCollett wants to merge 1 commit into
Conversation
When the relay-compiler is configured with `include_query_text: true` for persisted queries, generated artifacts carry a persisted `id`, the query `text`, and a `cacheID` (a hash of the text used for local caching) all at once. The current `RequestParameters` union only allows `cacheID` on the text-only variant (`id: null`), so an artifact with a non-null `id` plus a `cacheID` does not type-check. Add an optional `cacheID?: string` to the persisted-`id` variant so this compiler configuration is representable without widening the text-only variant.
Contributor
|
Thanks! This matches the Flow types. Makes sense. |
Contributor
|
@captbaritone has imported this pull request. If you are a Meta employee, you can view this in D114794036. |
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.
Summary
When the relay-compiler is configured with
include_query_text: truefor persisted queries, generated artifacts carry a persistedid, the querytext, and acacheID(a hash of the text, used for local caching) all at once.The current
RequestParametersunion only permitscacheIDon the text-only variant (the one withid: null):So an artifact with a non-null
idplus acacheIDdoes not type-check against either variant. This PR adds an optionalreadonly cacheID?: stringto the persisted-idvariant, which makes that compiler configuration representable without altering the existing text-only variant.This is a purely additive, optional field — no runtime behaviour changes, and existing artifacts that omit
cacheIDare unaffected.Motivation
We run relay-compiler with
persistConfig+include_query_text: trueso that artifacts carry both a persistedid(for id-first / trusted-documents requests) and thetext(for a safe deploy transition), together with thecacheIDthe compiler emits for local caching. The type currently doesn't describe artifacts that have all three, which we've been carrying as a local patch.Test plan
Type-only change to a Flow definition; adding an optional field to one member of the union is backwards compatible.
RequestParameterscontinues to type-check for all existing shapes, and now also accepts{ id, text, cacheID }.