Package org.apache.jmeter.protocol.http.util

# 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 Summary

Fields
Modifier and Type
Field
Description
`static final String`
`OPERATION_NAME_FIELD`
`static final String`
`QUERY_FIELD`
`static final String`
`VARIABLES_FIELD`

## Method Summary

Modifier and Type
Method
Description
`static boolean`
`isGraphQLContentType(String contentType)`
Return true if the content type is GraphQL content type (i.e.
`static String`
`queryToGetParamValue(String query)`
Convert the GraphQL Query input string into an HTTP GET request parameter value.
`static GraphQLRequestParams`
`toGraphQLRequestParams(byte[] postData, String contentEncoding)`
Parse `postData` and convert it to a `GraphQLRequestParams` object if it is a valid GraphQL post data.
`static GraphQLRequestParams`
`toGraphQLRequestParams(Arguments arguments, String contentEncoding)`
Parse `arguments` and convert it to a `GraphQLRequestParams` object if it has valid GraphQL HTTP arguments.
`static String`
`toPostBodyString(GraphQLRequestParams params)`
Convert the GraphQL request parameters input data to an HTTP POST body string.
`static String`
`variablesToGetParamValue(String variables)`
Convert the GraphQL Variables JSON input string into an HTTP GET request parameter value.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### VARIABLES_FIELD

public static final String VARIABLES_FIELD

See Also:
  - Constant Field Values

### OPERATION_NAME_FIELD

public static final String OPERATION_NAME_FIELD

See Also:
  - Constant Field Values

### QUERY_FIELD

public static final String QUERY_FIELD

See Also:
  - Constant Field Values

## 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