Class GraphQLRequest
java.lang.Object
com.graphql_java_generator.client.request.AbstractGraphQLRequest
com.graphql_java_generator.client.request.ObjectResponse
com.graphql_java_generator.domain.client.allGraphQLCases.GraphQLRequest
- Author:
- generated by graphql-java-generator
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.graphql_java_generator.client.request.AbstractGraphQLRequest
AbstractGraphQLRequest.Payload
-
Field Summary
Fields inherited from class com.graphql_java_generator.client.request.AbstractGraphQLRequest
packageName
-
Constructor Summary
ConstructorsConstructorDescriptionGraphQLRequest
(String graphQLRequest) GraphQLRequest
(org.springframework.graphql.client.GraphQlClient graphQlClient, String graphQLRequest, com.graphql_java_generator.annotation.RequestType requestType, String queryName, InputParameter... inputParams) -
Method Summary
Modifier and TypeMethodDescriptionexecMutation
(Object... paramsAndValues) This method executes the current GraphQL request as a full mutation request.execMutation
(Map<String, Object> parameters) This method executes the current GraphQL request as a full mutation request.This method executes the current GraphQL request as a full query request.This method executes the current GraphQL request as a full query request.execSubscription
(SubscriptionCallback<T> subscriptionCallback, Class<T> messageType, Object... paramsAndValues) This method executes the current GraphQL request as a full subscription request.execSubscription
(SubscriptionCallback<T> subscriptionCallback, Class<T> messageType, Map<String, Object> parameters) This method executes the current GraphQL request as a full subscription request.protected String
This method returns the package name, where the GraphQL generated classes are.protected Class<? extends GraphQLRequestObject>
Methods inherited from class com.graphql_java_generator.client.request.AbstractGraphQLRequest
exec, exec, execReactive, execReactive, getFragments, getGraphQLObjectMapper, getGraphQLRequest, getMutation, getPayload, getQuery, getRequestName, getRequestType, getSubscription, logExecution
-
Constructor Details
-
GraphQLRequest
-
GraphQLRequest
public GraphQLRequest(org.springframework.graphql.client.GraphQlClient graphQlClient, String graphQLRequest, com.graphql_java_generator.annotation.RequestType requestType, String queryName, InputParameter... inputParams) throws GraphQLRequestPreparationException
-
-
Method Details
-
execQuery
public MyQueryTypeResponse execQuery(Map<String, Object> parameters) throws GraphQLRequestExecutionExceptionThis method executes the current GraphQL request as a full query request. It offers a logging of the call (if in debug mode), or of the call and its parameters (if in trace mode).
Here is a sample (and please have a look to the graphql-java-generator website for more information):GraphQLRequest request; public void setup() { GraphQLRequest.setStaticConfiguration(...); // Preparation of the query request = myQueryType.getResponseBuilder() .withQueryResponseDef("query{hero(param:?heroParam) @include(if:true) {id name @skip(if: ?skip) appearsIn friends {id name}}}").build(); } public void doTheJob() { .. Map<String, Object> params = new HashMap<>(); params.put("heroParam", heroParamValue); params.put("skip", Boolean.FALSE); // This will set the value sinceValue to the sinceParam field parameter MyQueryTypeResponse response = request.exec(params); ... }
- Parameters:
parameters
- The list of values, for the bind variables defined in the query. If there is no bind variable in the defined Query, this argument may be null or an emptyMap
- Throws:
GraphQLRequestExecutionException
- When an error occurs during the request execution, typically a network error, an error from the GraphQL server or if the server response can't be parsed
-
execQuery
public MyQueryTypeResponse execQuery(Object... paramsAndValues) throws GraphQLRequestExecutionException This method executes the current GraphQL request as a full query request. It offers a logging of the call (if in debug mode), or of the call and its parameters (if in trace mode).
Here is a sample (and please have a look to the graphql-java-generator website for more information):GraphQLRequest request; public void setup() { GraphQLRequest.setStaticConfiguration(...); // Preparation of the query request = new GraphQLRequest("query{hero(param:?heroParam) @include(if:true) {id name @skip(if: ?skip) appearsIn friends {id name}}}").build(); } public void doTheJob() { .. // This will set the value sinceValue to the sinceParam field parameter MyQueryTypeResponse response = request.exec("heroParam", heroParamValue, "skip", Boolean.FALSE); ... }
- Parameters:
paramsAndValues
- This parameter contains all the name and values for the Bind Variables defined in the objectResponse parameter, that must be sent to the server. Optional parameter may not have a value. They will be ignored and not sent to the server. Mandatory parameter must be provided in this argument.
This parameter contains an even number of parameters: it must be a series of name and values : (paramName1, paramValue1, paramName2, paramValue2...)- Throws:
GraphQLRequestExecutionException
- When an error occurs during the request execution, typically a network error, an error from the GraphQL server or if the server response can't be parsed
-
execMutation
public AnotherMutationTypeResponse execMutation(Map<String, Object> parameters) throws GraphQLRequestExecutionExceptionThis method executes the current GraphQL request as a full mutation request. It offers a logging of the call (if in debug mode), or of the call and its parameters (if in trace mode).
Here is a sample (and please have a look to the graphql-java-generator website for more information):GraphQLRequest request; public void setup() { GraphQLRequest.setStaticConfiguration(...); // Preparation of the query request = myQueryType.getResponseBuilder() .withQueryResponseDef("mutation{hero(param:?heroParam) @include(if:true) {id name @skip(if: ?skip) appearsIn friends {id name}}}").build(); } public void doTheJob() { .. Map<String, Object> params = new HashMap<>(); params.put("heroParam", heroParamValue); params.put("skip", Boolean.FALSE); // This will set the value sinceValue to the sinceParam field parameter AnotherMutationTypeResponse response = request.exec(params); ... }
- Parameters:
parameters
- The list of values, for the bind variables defined in the query. If there is no bind variable in the defined Query, this argument may be null or an emptyMap
- Throws:
GraphQLRequestExecutionException
- When an error occurs during the request execution, typically a network error, an error from the GraphQL server or if the server response can't be parsed
-
execMutation
public AnotherMutationTypeResponse execMutation(Object... paramsAndValues) throws GraphQLRequestExecutionException This method executes the current GraphQL request as a full mutation request. It offers a logging of the call (if in debug mode), or of the call and its parameters (if in trace mode).
Here is a sample (and please have a look to the graphql-java-generator website for more information):GraphQLRequest request; public void setup() { GraphQLRequest.setStaticConfiguration(...); // Preparation of the query request = new GraphQLRequest("mutation{hero(param:?heroParam) @include(if:true) {id name @skip(if: ?skip) appearsIn friends {id name}}}").build(); } public void doTheJob() { .. // This will set the value sinceValue to the sinceParam field parameter AnotherMutationTypeResponse response = request.exec("heroParam", heroParamValue, "skip", Boolean.FALSE); ... }
- Parameters:
paramsAndValues
- This parameter contains all the name and values for the Bind Variables defined in the objectResponse parameter, that must be sent to the server. Optional parameter may not have a value. They will be ignored and not sent to the server. Mandatory parameter must be provided in this argument.
This parameter contains an even number of parameters: it must be a series of name and values : (paramName1, paramValue1, paramName2, paramValue2...)- Throws:
GraphQLRequestExecutionException
- When an error occurs during the request execution, typically a network error, an error from the GraphQL server or if the server response can't be parsed
-
execSubscription
public <T> SubscriptionClient execSubscription(SubscriptionCallback<T> subscriptionCallback, Class<T> messageType, Map<String, Object> parameters) throws GraphQLRequestExecutionExceptionThis method executes the current GraphQL request as a full subscription request. It offers a logging of the call (if in debug mode), or of the call and its parameters (if in trace mode). You can to the graphql-java-generator website to read more information.
Please note:- Using partial request is easier
- The full request may bot contain more than one subscription at a time
GraphQLRequest request; public void setup() { GraphQLRequest.setStaticConfiguration(...); // Preparation of the query request = myQueryType.getResponseBuilder() .withQueryResponseDef("subscription{hero(param:?heroParam) @include(if:true) {id name @skip(if: ?skip) appearsIn friends {id name}}}").build(); } public void doTheJob() { .. Map<String, Object> params = new HashMap<>(); params.put("heroParam", heroParamValue); params.put("skip", Boolean.FALSE); // This will set the value sinceValue to the sinceParam field parameter TheSubscriptionTypeResponse response = request.exec(params); ... }
- Type Parameters:
T
- The type that must is returned by the subscription in the GraphQL schema, which is actually the type that will be sent in each notification received from this subscription.- Parameters:
subscriptionCallback
- The object that will be called each time a message is received, or an error on the subscription occurs. This object is provided by the application.messageType
- The T classparameters
- The list of values, for the bind variables defined in the query. If there is no bind variable in the defined Query, this argument may be null or an emptyMap
- Returns:
- The Subscription client. It allows to stop the subscription, by executing its
SubscriptionClient.unsubscribe()
method. This will stop the incoming notification flow, and will free resources on both the client and the server. - Throws:
GraphQLRequestExecutionException
- When an error occurs during the request execution, typically a network error, an error from the GraphQL server or if the server response can't be parsed
-
execSubscription
public <T> SubscriptionClient execSubscription(SubscriptionCallback<T> subscriptionCallback, Class<T> messageType, Object... paramsAndValues) throws GraphQLRequestExecutionException This method executes the current GraphQL request as a full subscription request. It offers a logging of the call (if in debug mode), or of the call and its parameters (if in trace mode). You can to the graphql-java-generator website to read more information.
Please note:- Using partial request is easier
- The full request may bot contain more than one subscription at a time
GraphQLRequest request; public void setup() { GraphQLRequest.setStaticConfiguration(...); // Preparation of the query request = new GraphQLRequest("subscription{hero(param:?heroParam) @include(if:true) {id name @skip(if: ?skip) appearsIn friends {id name}}}").build(); } public void doTheJob() { .. // This will set the value sinceValue to the sinceParam field parameter TheSubscriptionTypeResponse response = request.exec("heroParam", heroParamValue, "skip", Boolean.FALSE); ... }
- Type Parameters:
T
- The type that must is returned by the subscription in the GraphQL schema, which is actually the type that will be sent in each notification received from this subscription.- Parameters:
subscriptionCallback
- The object that will be called each time a message is received, or an error on the subscription occurs. This object is provided by the application.messageType
- The T classparamsAndValues
- This parameter contains all the name and values for the Bind Variables defined in the objectResponse parameter, that must be sent to the server. Optional parameter may not have a value. They will be ignored and not sent to the server. Mandatory parameter must be provided in this argument.
This parameter contains an even number of parameters: it must be a series of name and values : (paramName1, paramValue1, paramName2, paramValue2...)- Returns:
- The Subscription client. It allows to stop the subscription, by executing its
SubscriptionClient.unsubscribe()
method. This will stop the incoming notification flow, and will free resources on both the client and the server. - Throws:
GraphQLRequestExecutionException
- When an error occurs during the request execution, typically a network error, an error from the GraphQL server or if the server response can't be parsed
-
getGraphQLClassesPackageName
This method returns the package name, where the GraphQL generated classes are. It's used to load the class definition, and get the GraphQL metadata coming from the GraphQL schema.- Specified by:
getGraphQLClassesPackageName
in classAbstractGraphQLRequest
- Returns:
-
getQueryContext
- Specified by:
getQueryContext
in classAbstractGraphQLRequest
- Throws:
GraphQLRequestPreparationException
-
getMutationContext
- Specified by:
getMutationContext
in classAbstractGraphQLRequest
- Throws:
GraphQLRequestPreparationException
-
getSubscriptionContext
- Specified by:
getSubscriptionContext
in classAbstractGraphQLRequest
- Throws:
GraphQLRequestPreparationException
-
getSubscriptionClass
- Specified by:
getSubscriptionClass
in classAbstractGraphQLRequest
-