Skip to content

Allow optional cacheID on the persisted-id RequestParameters variant - #5383

Open
GregoryCollett wants to merge 1 commit into
facebook:mainfrom
GregoryCollett:gc-request-parameters-optional-cacheid
Open

Allow optional cacheID on the persisted-id RequestParameters variant#5383
GregoryCollett wants to merge 1 commit into
facebook:mainfrom
GregoryCollett:gc-request-parameters-optional-cacheid

Conversation

@GregoryCollett

Copy link
Copy Markdown

Summary

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 permits cacheID on the text-only variant (the one with id: null):

export type RequestParameters =
  | {
      readonly id: string,
      readonly text: string | null,
      // ...no cacheID
    }
  | {
      readonly cacheID: string,
      readonly id: null,
      readonly text: string | null,
      // ...
    };

So an artifact with a non-null id plus a cacheID does not type-check against either variant. This PR adds an optional readonly cacheID?: string to the persisted-id variant, 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 cacheID are unaffected.

Motivation

We run relay-compiler with persistConfig + include_query_text: true so that artifacts carry both a persisted id (for id-first / trusted-documents requests) and the text (for a safe deploy transition), together with the cacheID the 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. RequestParameters continues to type-check for all existing shapes, and now also accepts { id, text, cacheID }.

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.
@meta-cla meta-cla Bot added the CLA Signed label Jul 28, 2026
@captbaritone

Copy link
Copy Markdown
Contributor

Thanks! This matches the Flow types. Makes sense.

@meta-codesync

meta-codesync Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

@captbaritone has imported this pull request. If you are a Meta employee, you can view this in D114794036.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants