feat(graphql): GraphQL operations as data sources (7.1, C4)#61
Merged
officialCodeWork merged 1 commit intoJul 17, 2026
Merged
Conversation
Recognize the GraphQL a component runs and treat each operation as a data source, reusing the existing data-source node + fetches-from wiring (no schema change — `graphql` was already a DataSourceKind). - New graphql.ts: parseGraphqlOperation reads operation type/name (+ root fields as an anonymous-op fallback) from a gql document; graphqlOperationFromArg resolves a hook argument to an operation — inline gql/graphql tagged template, or an identifier followed via getDefinitionNodes() so an imported/co-located gql const resolves cross-file. - detectDataSource gains a GraphQL branch before the react-query branch (Apollo/ urql reuse useQuery/useMutation, so it only claims the call when the argument is an actual gql document, else falls through). Emits sourceKind "graphql", method = query/mutation/subscription, endpoint = operation name (the value federation/attribution join on). - New fixture c4-graphql (imported-const useQuery/useMutation + inline useSubscription); 9 unit tests incl. react-query disambiguation on c5. eval 326/0/0/0, determinism 1.000, all metrics 1.000; parser-react 160 tests, typecheck + lint clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Phase 7.1 — GraphQL adapter (failure mode C4) · first Phase 7 step
Recognizes the GraphQL a component runs and treats each operation as a data source, reusing the existing data-source node +
fetches-fromwiring. No schema change —graphqlwas already aDataSourceKind.Changes
graphql.tsparseGraphqlOperation— reads operation type/name (and root selection fields as an anonymous-op fallback) from a gql document; ignores#comments; handles shorthand{ … }; returns null for fragment-only docs.graphqlOperationFromArg— resolves a hook's first argument to an operation: an inlinegql/graphqltagged template, or an identifier followed viagetDefinitionNodes()so an imported/co-located gql const resolves cross-file.detectDataSourcegains a GraphQL branch before the react-query branch. Apollo/urql reuseuseQuery/useMutation, so it only claims the call when the argument is an actual gql document — otherwise it falls through and react-query handles it. EmitssourceKind: "graphql",method= query/mutation/subscription,endpoint= operation name (the value federation/attribution will join on).Fixture & tests
c4-graphql: imported-constuseQuery(GetUsers) +useMutation(CreateUser) + inlineuseSubscription(OnTick) → onegraphqlsource each with the right method and afetches-fromedge.queryFnuseQuery/useMutationstill classify as react-query, zero graphql sources).Verification
pnpm eval→ 326 pass · determinism 1.000 · all metrics 1.000Codegen response types (feeding 5.5) deferred — needs a
.graphql/codegen fixture; the operation→data-source spine here is what unblocks federation (7.6). 7.2–7.6 remain sketch-level pending 0.5.0 tester feedback. Tracker updated.🤖 Generated with Claude Code