mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 13:00:33 +01:00
How do I use GraphQLMatcher for file mapping #705
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @noxfate on GitHub (Jul 18, 2025).
Originally assigned to: @StefH on GitHub.
Hi, I want to ask question about GraphQLMatcher and how to use them.
I've been trying to use them in both format, both on C# and Json Mapping but found no success. Basically, I don't understand the feature in overall.
Do I have to provided schema first ? then start mocking the query? and how would that look like especially in Json Mapping. To clarify my use case, let's say I have this as my schema for entire application.
How do I match with query for /graphql with and stub the response
Currently, my work around is to use
JsonPartialMatcherbut proven to not effective and I really want to try this feature.I can help PR to update the docs once I can understand how its work. Thanks in advance
@StefH commented on GitHub (Jul 18, 2025):
You can take a look here::
@noxfate commented on GitHub (Jul 19, 2025):
looks at the test file and documentation, still have questions. I see that in test requires 2 input
TestSchemaand the actual queryinput. The test is isolated to only focus on matcher, but Im not sure what will it looks like for the C# and Json Mapping file config. The documentation only show how to register theTestSchemapart.@StefH commented on GitHub (Jul 19, 2025):
I see your point, and I must admin the functionality is hard to understand, and not all is implemented, and the examples are not complete.
However I did update the WIKI - GraphQLMatcher page.
In short:
You can define 1 schema for the entire application, but that means that you need also another Body matcher, like JsonPartialMatcher or JsonPartialWildcardMatcher to further refine the matching.
The
WithGraphQLSchemais mostly used to verify that the json request is a valid request according to the schema.But can also define small schemas which should only match 1 request.
In general I think some more logic can be defined in the GraphQLMatcher, however I do not know yet how.
And I noticed that Mutations are not supported at all.
@StefH commented on GitHub (Jul 19, 2025):
See also
https://github.com/wiremock/WireMock.Net/pull/1335
@noxfate commented on GitHub (Jul 21, 2025):
I see and noted on the mutation. So I assume that it should work like this on Json Mapping ? or this feature isn't support at the moment?