feat(g14a): GraphQL query matching, validated against the GraphQL extension#51
Merged
Conversation
…ension
GraphQL parity by matcher, not transport: a GraphQL request is an ordinary
POST /graphql with a {"query": ...} body, so the serving path is unchanged —
GraphQL adds a request matcher that understands query equivalence.
GraphqlQueryMatcher normalizes exactly as the reference extension does: parse
both queries (GraphQL-Parser), sort the AST (recursively order selections and
arguments bottom-up by printed form — the community extension uses
graphql-java's AstSorter), print canonically, and string-compare. So equal
queries match regardless of whitespace AND field/argument order; a syntax
error on either side is a no-match. The adapter recognizes the
graphql-body-matcher customMatcher (parameters.query = the expected query;
the key was discovered from the extension source); any other customMatcher
name still resolves via the G10 registry.
Validated against the community WireMock GraphQL extension oracle
(io.github.nilwurtz, loaded via --extensions): the same stub in both sides,
five query variants POSTed to /graphql (exact, reformatted, reordered
fields, different, invalid) — the match/no-match decision agrees on every
one. Suite green (102 differential, 9 application).
Deferred (tracked): variables + operationName matching; GraphQL response
templating.
Refs: G14a
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.
G14a — GraphQL query matching
The first GraphQL slice. Unlike gRPC, GraphQL needs no new transport — a GraphQL request is an ordinary
POST /graphqlwith a{"query": …}body. So GraphQL is a request matcher that understands query equivalence; the whole serving path is unchanged.Normalization — matches the reference exactly
The community WireMock GraphQL extension parses both queries, runs graphql-java's
AstSorter, then compares withAstComparator— so equal queries match regardless of whitespace AND field/argument order.GraphqlQueryMatcherreproduces this with GraphQL-Parser: parse → recursively sort selections + arguments bottom-up (by printed form) → print canonically → string-compare. A syntax error on either side is a no-match.Wiring
The adapter recognizes the
graphql-body-matchercustomMatcherand builds aGraphqlQueryMatcher(parameters.query). (The param keyquerywas discovered from the extension source — the natural guessesexpectedQuery/requestJsonare not it.) Any othercustomMatchername still resolves via the G10 registry.Validation
G14aGraphqlTests.QueryMatching_AgreesWithTheOracle: the community extension (io.github.nilwurtz, loaded via--extensions) is the oracle. The same stub is loaded into both sides and five query variants are POSTed to/graphql— exact, reformatted (whitespace), reordered fields, a different query, and a syntactically invalid one. The match/no-match decision agrees on every variant.Full suite: 102 differential, 9 application, 0 warnings.
Explicitly deferred (tracked)
variables+operationNamematching (the extension also compares those); GraphQL response templating.New dep:
GraphQL-Parser 9.5.1(graphql-dotnet's parser, MIT), used only insideMockifyr.Matching. The extension jar is fetched from Maven Central at test time (cached), not committed.Docs:
docs/parity/g14-graphql.md(new),docs/roadmap.md(G14a ticked).🤖 Generated with Claude Code