Class GraphQLRequestParamUtils

java.lang.Object
org.apache.jmeter.protocol.http.util.GraphQLRequestParamUtils

public final class GraphQLRequestParamUtils extends Object
Utilities to (de)serialize GraphQL request parameters.
  • Field Details

  • Method Details

    • isGraphQLContentType

      public static boolean isGraphQLContentType(String contentType)
      Return true if the content type is GraphQL content type (i.e. 'application/json').
      Parameters:
      contentType - Content-Type value
      Returns:
      true if the content type is GraphQL content type
    • toPostBodyString

      public static String toPostBodyString(GraphQLRequestParams params)
      Convert the GraphQL request parameters input data to an HTTP POST body string.
      Parameters:
      params - GraphQL request parameter input data
      Returns:
      an HTTP POST body string converted from the GraphQL request parameters input data
      Throws:
      RuntimeException - if JSON serialization fails for some reason due to any runtime environment issues
    • queryToGetParamValue

      public static String queryToGetParamValue(String query)
      Convert the GraphQL Query input string into an HTTP GET request parameter value.
      Parameters:
      query - the GraphQL Query input string
      Returns:
      an HTTP GET request parameter value converted from the GraphQL Query input string
    • variablesToGetParamValue

      public static String variablesToGetParamValue(String variables)
      Convert the GraphQL Variables JSON input string into an HTTP GET request parameter value.
      Parameters:
      variables - the GraphQL Variables JSON input string
      Returns:
      an HTTP GET request parameter value converted from the GraphQL Variables JSON input string
    • toGraphQLRequestParams

      public static GraphQLRequestParams toGraphQLRequestParams(byte[] postData, String contentEncoding) throws com.fasterxml.jackson.core.JsonProcessingException, UnsupportedEncodingException
      Parse postData and convert it to a GraphQLRequestParams object if it is a valid GraphQL post data.
      Parameters:
      postData - post data
      contentEncoding - content encoding
      Returns:
      a converted GraphQLRequestParams object form the postData
      Throws:
      IllegalArgumentException - if postData is not a GraphQL post JSON data or not a valid JSON
      com.fasterxml.jackson.core.JsonProcessingException - if it fails to serialize a parsed JSON object to string
      UnsupportedEncodingException - if it fails to decode parameter value
    • toGraphQLRequestParams

      public static GraphQLRequestParams toGraphQLRequestParams(Arguments arguments, String contentEncoding) throws UnsupportedEncodingException
      Parse arguments and convert it to a GraphQLRequestParams object if it has valid GraphQL HTTP arguments.
      Parameters:
      arguments - arguments
      contentEncoding - content encoding
      Returns:
      a converted GraphQLRequestParams object form the arguments
      Throws:
      IllegalArgumentException - if arguments does not contain valid GraphQL request arguments
      UnsupportedEncodingException - if it fails to decode parameter value