Class GraphQLRequestParamUtils
java.lang.Object
org.apache.jmeter.protocol.http.util.GraphQLRequestParamUtils
Utilities to (de)serialize GraphQL request parameters.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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) ParsepostData
and convert it to aGraphQLRequestParams
object if it is a valid GraphQL post data.static GraphQLRequestParams
toGraphQLRequestParams
(Arguments arguments, String contentEncoding) Parsearguments
and convert it to aGraphQLRequestParams
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.
-
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 ParsepostData
and convert it to aGraphQLRequestParams
object if it is a valid GraphQL post data.- Parameters:
postData
- post datacontentEncoding
- content encoding- Returns:
- a converted
GraphQLRequestParams
object form thepostData
- Throws:
IllegalArgumentException
- ifpostData
is 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 Parsearguments
and convert it to aGraphQLRequestParams
object if it has valid GraphQL HTTP arguments.- Parameters:
arguments
- argumentscontentEncoding
- content encoding- Returns:
- a converted
GraphQLRequestParams
object form thearguments
- Throws:
IllegalArgumentException
- ifarguments
does not contain valid GraphQL request argumentsUnsupportedEncodingException
- if it fails to decode parameter value
-