Class GraphQLAstMatcher

java.lang.Object
org.mockserver.matchers.GraphQLAstMatcher

public class GraphQLAstMatcher extends Object
AST-aware GraphQL body matcher. Supports:

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 Details

    • GraphQLAstMatcher

      public GraphQLAstMatcher(GraphQLBody body)
  • Method Details

    • matches

      public boolean matches(String actualBody)
      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