Package org.mockserver.matchers
Class GraphQLAstMatcher
java.lang.Object
org.mockserver.matchers.GraphQLAstMatcher
AST-aware GraphQL body matcher. Supports:
SelectionSetMatchType.AST_EXACT— operation type, name, and top-level field set must match exactlySelectionSetMatchType.AST_SUBSET— expected fields must be a subset of actual query's top-level fields
This is a lightweight parser — it does not use graphql-java. It extracts operation type/name and top-level field names from GraphQL query strings using character-level parsing that handles strings, comments, and brace nesting.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
GraphQLAstMatcher
-
-
Method Details
-
matches
Match the actual request body against the expected GraphQL body using AST_EXACT or AST_SUBSET mode.- Parameters:
actualBody- the raw request body string (may be a JSON wrapper or raw GraphQL)- Returns:
- true if the body matches according to the configured mode
-