public class GraphQLRequest extends ObjectResponse
Author:
generated by graphql-java-generator
See Also:
  • Constructor Details

  • Method Details

    • execQuery

      public MyQueryTypeResponse execQuery(Map<String,Object> parameters) 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 = 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 empty Map
      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

      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 = 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 empty Map
      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 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
      Here is a sample (and please have a look to the GraphQL site for more information):
       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 class
      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 empty Map
      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
      Here is a sample (and please have a look to the GraphQL site for more information):
       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 class
      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...)
      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

      protected String 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 class AbstractGraphQLRequest
      Returns:
    • getQueryContext

      public QueryField getQueryContext() throws GraphQLRequestPreparationException
      Specified by:
      getQueryContext in class AbstractGraphQLRequest
      Throws:
      GraphQLRequestPreparationException
    • getMutationContext

      public QueryField getMutationContext() throws GraphQLRequestPreparationException
      Specified by:
      getMutationContext in class AbstractGraphQLRequest
      Throws:
      GraphQLRequestPreparationException
    • getSubscriptionContext

      public QueryField getSubscriptionContext() throws GraphQLRequestPreparationException
      Specified by:
      getSubscriptionContext in class AbstractGraphQLRequest
      Throws:
      GraphQLRequestPreparationException
    • getSubscriptionClass

      protected Class<? extends GraphQLRequestObject> getSubscriptionClass()
      Specified by:
      getSubscriptionClass in class AbstractGraphQLRequest