Class GraphqlBodyMatcher

  • All Implemented Interfaces:
    com.github.tomakehurst.wiremock.extension.Extension , com.github.tomakehurst.wiremock.matching.NamedValueMatcher , com.github.tomakehurst.wiremock.matching.ValueMatcher

    
    public final class GraphqlBodyMatcher
    extends RequestMatcherExtension
                        
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
      public final static String extensionName
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      MatchResult match(Request request, Parameters parameters) Compares the given Request against the expected GraphQL query, variables, and operationName to determine if they match.
      String getName()
      final static GraphqlBodyMatcher withRequestQueryAndVariables(String expectedQuery, String expectedVariables) Creates a new instance of GraphqlBodyMatcher with the given GraphQL query string and variables.
      final static GraphqlBodyMatcher withRequestQueryAndVariables(String expectedQuery) Creates a new instance of GraphqlBodyMatcher with the given GraphQL query string and variables.
      final static GraphqlBodyMatcher withRequestJson(String expectedJson) Creates a new instance of GraphqlBodyMatcher with the given raw JSON string containing a GraphQL query and optional variables.
      final static Parameters withRequest(String expectedJson) Creates a Parameters instance containing the given raw JSON string expected in the GraphQL request.
      final static Parameters parameters(String query, Map<String, Object> variables, String operationName) Creates a Parameters instance containing the query and optionally the variables and operationName.
      final static Parameters parameters(String query, Map<String, Object> variables) Creates a Parameters instance containing the query and optionally the variables and operationName.
      final static Parameters parameters(String query) Creates a Parameters instance containing the query and optionally the variables and operationName.
      • Methods inherited from class com.github.tomakehurst.wiremock.matching.RequestMatcherExtension

        match
      • Methods inherited from class com.github.tomakehurst.wiremock.matching.RequestMatcher

        equals, getExpected, hashCode
      • Methods inherited from class com.github.tomakehurst.wiremock.extension.Extension

        start, stop
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GraphqlBodyMatcher

        GraphqlBodyMatcher()
    • Method Detail

      • match

         MatchResult match(Request request, Parameters parameters)

        Compares the given Request against the expected GraphQL query, variables, and operationName to determine if they match. If query, variables, and operationName are semantically equal, it returns an exact match result; otherwise, it returns a no match result.

        Parameters:
        request - The incoming request to match against the expected query and variables.
        parameters - Additional parameters that may be used for matching.
      • withRequestQueryAndVariables

        @Deprecated(message = "Use parameters instead. Along with Wiremock.requestMatching(String, Parameters) or MappingBuilder#andMatching(String, Parameters).")@JvmOverloads() final static GraphqlBodyMatcher withRequestQueryAndVariables(String expectedQuery, String expectedVariables)

        Creates a new instance of GraphqlBodyMatcher with the given GraphQL query string and variables. The query string and variables are wrapped in a JSON object with "query" and "variables" fields, parsed, validated, and normalized before being used for matching.

        Parameters:
        expectedQuery - The GraphQL query string that the matcher expects in requests.
        expectedVariables - The variables associated with the GraphQL query as a JSON string.
      • withRequestQueryAndVariables

        @Deprecated(message = "Use parameters instead. Along with Wiremock.requestMatching(String, Parameters) or MappingBuilder#andMatching(String, Parameters).")@JvmOverloads() final static GraphqlBodyMatcher withRequestQueryAndVariables(String expectedQuery)

        Creates a new instance of GraphqlBodyMatcher with the given GraphQL query string and variables. The query string and variables are wrapped in a JSON object with "query" and "variables" fields, parsed, validated, and normalized before being used for matching.

        Parameters:
        expectedQuery - The GraphQL query string that the matcher expects in requests.
      • withRequestJson

        @Deprecated(message = "Use parameters instead. Along with Wiremock.requestMatching(String, Parameters) or MappingBuilder#andMatching(String, Parameters).") final static GraphqlBodyMatcher withRequestJson(String expectedJson)

        Creates a new instance of GraphqlBodyMatcher with the given raw JSON string containing a GraphQL query and optional variables. The JSON is expected to have a "query" field with the query string and an optional "variables" field containing the variables. The query is parsed, validated, and normalized before being used for matching.

        Parameters:
        expectedJson - The raw JSON string containing the GraphQL query and optional variables that the matcher expects in requests.
      • withRequest

        @Deprecated(message = "Use parameters instead.") final static Parameters withRequest(String expectedJson)

        Creates a Parameters instance containing the given raw JSON string expected in the GraphQL request.

        This method is used to set up JSON expected in remote requests. The expectedJson parameter should be a raw JSON string that encapsulates the expected query and optionally variables for the GraphQL request. This string is used to create a parameters object utilized internally in the GraphqlBodyMatcher.

        Parameters:
        expectedJson - A raw JSON string that contains the GraphQL query and optionally variables expected in the requests.
      • parameters

        @JvmOverloads() final static Parameters parameters(String query, Map<String, Object> variables, String operationName)

        Creates a Parameters instance containing the query and optionally the variables and operationName.

        Parameters:
        query - A GraphQL query string.
        variables - An optional map of variables used in the GraphQL query.
        operationName - The optional name of the operation in the GraphQL query.
      • parameters

        @JvmOverloads() final static Parameters parameters(String query, Map<String, Object> variables)

        Creates a Parameters instance containing the query and optionally the variables and operationName.

        Parameters:
        query - A GraphQL query string.
        variables - An optional map of variables used in the GraphQL query.
      • parameters

        @JvmOverloads() final static Parameters parameters(String query)

        Creates a Parameters instance containing the query and optionally the variables and operationName.

        Parameters:
        query - A GraphQL query string.