Skip to content

Fix ra-data-graphql introspection losing fields with a custom __typename - #11437

Open
TemRevil wants to merge 1 commit into
marmelab:masterfrom
TemRevil:fix/graphql-introspection-no-cache
Open

TemRevil wants to merge 1 commit into
marmelab:masterfrom
TemRevil:fix/graphql-introspection-no-cache

Conversation

@TemRevil

@TemRevil TemRevil commented Nov 2, 2026

Copy link
Copy Markdown

Fixes #10215

introspectSchema fetches the schema with fetchPolicy: 'network-only'. That skips the cache read but still writes the result to the Apollo cache and returns what is read back from it. Some servers (pg_graphql, for example) set __typename on introspection types to the type's own name, like BigFloat. The cache then normalizes those entries, and the returned types come back as just { __typename: 'BigFloat' }.

Switching to no-cache returns the raw response, which is what introspection wants anyway. I left the data queries in index.ts alone.

I added a test with a real ApolloClient and InMemoryCache and a type with a custom __typename. It fails with network-only and passes with no-cache.

Introspection used fetchPolicy 'network-only', which still writes the result to
the Apollo cache and reads it back. For servers that return the type name as
__typename of an introspection type (e.g. pg_graphql), the cache normalizes
those entries and the fields are lost. Use 'no-cache' instead.

This branch has not been deployed

No deployments
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.

ra-data-graphql Introspection Result Generation Affected by Apollo Client Cache Policy

2 participants