Class GraphQLRequestParamUtils
java.lang.Object
org.apache.jmeter.protocol.http.util.GraphQLRequestParamUtils
Utilities to (de)serialize GraphQL request parameters.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisGraphQLContentType(String contentType) Return true if the content type is GraphQL content type (i.e.static StringqueryToGetParamValue(String query) Convert the GraphQL Query input string into an HTTP GET request parameter value.static GraphQLRequestParamstoGraphQLRequestParams(byte[] postData, String contentEncoding) ParsepostDataand convert it to aGraphQLRequestParamsobject if it is a valid GraphQL post data.static GraphQLRequestParamstoGraphQLRequestParams(Arguments arguments, String contentEncoding) Parseargumentsand convert it to aGraphQLRequestParamsobject if it has valid GraphQL HTTP arguments.static StringtoPostBodyString(GraphQLRequestParams params) Convert the GraphQL request parameters input data to an HTTP POST body string.static StringvariablesToGetParamValue(String variables) Convert the GraphQL Variables JSON input string into an HTTP GET request parameter value.
-
Field Details
-
VARIABLES_FIELD
- See Also:
-
OPERATION_NAME_FIELD
- See Also:
-
QUERY_FIELD
- See Also:
-
-
Method Details
-
isGraphQLContentType
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
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
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
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 ParsepostDataand convert it to aGraphQLRequestParamsobject if it is a valid GraphQL post data.- Parameters:
postData- post datacontentEncoding- content encoding- Returns:
- a converted
GraphQLRequestParamsobject form thepostData - Throws:
IllegalArgumentException- ifpostDatais not a GraphQL post JSON data or not a valid JSONcom.fasterxml.jackson.core.JsonProcessingException- if it fails to serialize a parsed JSON object to stringUnsupportedEncodingException- if it fails to decode parameter value
-
toGraphQLRequestParams
public static GraphQLRequestParams toGraphQLRequestParams(Arguments arguments, String contentEncoding) throws UnsupportedEncodingException Parseargumentsand convert it to aGraphQLRequestParamsobject if it has valid GraphQL HTTP arguments.- Parameters:
arguments- argumentscontentEncoding- content encoding- Returns:
- a converted
GraphQLRequestParamsobject form thearguments - Throws:
IllegalArgumentException- ifargumentsdoes not contain valid GraphQL request argumentsUnsupportedEncodingException- if it fails to decode parameter value
-