Class SubscriptionExecutorMySchema
java.lang.Object
com.graphql_java_generator.domain.client.forum.SubscriptionExecutorMySchema
- All Implemented Interfaces:
GraphQLSubscriptionExecutor
- Direct Known Subclasses:
Subscription
@Component
public class SubscriptionExecutorMySchema
extends Object
implements GraphQLSubscriptionExecutor
This class contains the methods that allows the execution of the subscriptions that are defined in the Subscription
of the GraphQL schema.
These methods allows:
These methods allows:
- Preparation of partial subscription requests
- Execution of partial prepared subscription requests
- Execution of partial direct subscription requests
- Author:
- generated by graphql-java-generator
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexec
(ObjectResponse objectResponse, SubscriptionCallback<?> subscriptionCallback, Object... paramsAndValues) This method takes a full request definition, and executes it against the GraphQL server.exec
(String queryResponseDef, SubscriptionCallback<?> subscriptionCallback, Object... paramsAndValues) This method takes a full request definition, and executes it against the GraphQL server.execWithBindValues
(ObjectResponse objectResponse, SubscriptionCallback<?> subscriptionCallback, Map<String, Object> parameters) This method takes a full request definition, and executes it against the GraphQL server.execWithBindValues
(String queryResponseDef, SubscriptionCallback<?> subscriptionCallback, Map<String, Object> parameters) This method takes a full request definition, and executes the it against the GraphQL server.getGraphQLRequest
(String fullRequest) Get theGraphQLRequest
for full request.Get theBuilder
for a full request, as expected by the exec and execWithBindValues methods.getSubscribeToNewPostGraphQLRequest
(String partialRequest) Get theGraphQLRequest
for the subscribeToNewPost executor, created with the given Partial request.Get theBuilder
for the Post, as expected by the subscribeToNewPost subscription.subscribeToNewPost
(ObjectResponse objectResponse, SubscriptionCallback<Post> subscriptionCallback, String boardName, Object... paramsAndValues) This method registers a subscription, by executing a direct partial request against the GraphQL server.subscribeToNewPost
(String queryResponseDef, SubscriptionCallback<Post> subscriptionCallback, String boardName, Object... paramsAndValues) This method registers a subscription, by executing a direct partial request against the GraphQL server.subscribeToNewPostWithBindValues
(ObjectResponse objectResponse, SubscriptionCallback<Post> subscriptionCallback, String boardName, Map<String, Object> parameters) This method registers a subscription, by executing a direct partial request against the GraphQL server.subscribeToNewPostWithBindValues
(String queryResponseDef, SubscriptionCallback<Post> subscriptionCallback, String boardName, Map<String, Object> parameters) This method registers a subscription, by executing a direct partial request against the GraphQL server.
-
Constructor Details
-
SubscriptionExecutorMySchema
public SubscriptionExecutorMySchema()
-
-
Method Details
-
execWithBindValues
public SubscriptionClient execWithBindValues(String queryResponseDef, SubscriptionCallback<?> subscriptionCallback, Map<String, Object> parameters) throws GraphQLRequestExecutionException, GraphQLRequestPreparationExceptionThis method takes a full request definition, and executes the it against the GraphQL server. That is, the request contains the full string that follows the query/mutation/subscription keyword.
It offers a logging of the call (if in debug mode), or of the call and its parameters (if in trace mode).
For instance:Map<String, Object> params = new HashMap<>(); params.put("heroParam", heroParamValue); params.put("skip", Boolean.FALSE); MyQueryType response = myQueryType.execWithBindValues("subscription {subscribeToNewHeros {id name}}", params); Character c = response.getHero();
- Parameters:
queryResponseDef
- The response definition of the subscription, in the native GraphQL format (see here above). It must ommit the query/mutation/subscription keyword, and start by the first { that follows.It may contain directives, as explained in the GraphQL specs.parameters
- The map 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
. The key is the parameter name, as defined in the query (in the above sample: heroParam is an optional parameter and skip is a mandatory one). The value is the parameter vale in its Java type (for instance aDate
for theGraphQLScalarTypeDate
). The parameters which value is missing in this map will no be transmitted toward the GraphQL server.- Returns:
- The
SubscriptionClient
that allows the caller to act on the subscribed subscription. - Throws:
GraphQLRequestPreparationException
- When an error occurs during the request preparation, typically when building theObjectResponse
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
-
exec
public SubscriptionClient exec(String queryResponseDef, SubscriptionCallback<?> subscriptionCallback, Object... paramsAndValues) throws GraphQLRequestExecutionException, GraphQLRequestPreparationException This method takes a full request definition, and executes it against the GraphQL server. That is, the query contains the full string that follows the query/mutation/subscription keyword.
It offers a logging of the call (if in debug mode), or of the call and its parameters (if in trace mode).
For instance:MyQueryType response = myQueryType.execWithBindValues( "{hero(param:?heroParam) @include(if:true) {id name @skip(if: ?skip) appearsIn friends {id name}}}", "heroParam", heroParamValue, "skip", Boolean.FALSE); Character c = response.getHero();
- Parameters:
queryResponseDef
- The response definition of the query, in the native GraphQL format (see here above). It must ommit the query/mutation/subscription keyword, and start by the first { that follows.It may contain directives, as explained in the GraphQL specs.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
SubscriptionClient
that allows the caller to act on the subscribed subscription. - Throws:
GraphQLRequestPreparationException
- When an error occurs during the request preparation, typically when building theObjectResponse
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
-
execWithBindValues
public SubscriptionClient execWithBindValues(ObjectResponse objectResponse, SubscriptionCallback<?> subscriptionCallback, Map<String, Object> parameters) throws GraphQLRequestExecutionExceptionThis method takes a full request definition, and executes it against the GraphQL server. That is, the query contains the full string that follows the query/mutation/subscription keyword.
It offers a logging of the call (if in debug mode), or of the call and its parameters (if in trace mode).
For instance:ObjectResponse response; public void setup() { // Preparation of the query objectResponse = myQueryType.getResponseBuilder() .withQueryResponseDef("{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 MyQueryType response = queryType.execWithBindValues(objectResponse, params); Character c = response.getHero(); ... }
- Parameters:
objectResponse
- The definition of the response format, that describes what the GraphQL server is expected to returnparameters
- 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
SubscriptionClient
that allows the caller to act on the subscribed subscription. - 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
-
exec
public SubscriptionClient exec(ObjectResponse objectResponse, SubscriptionCallback<?> subscriptionCallback, Object... paramsAndValues) throws GraphQLRequestExecutionException This method takes a full request definition, and executes it against the GraphQL server. That is, the query contains the full string that follows the query/mutation/subscription keyword.
It offers a logging of the call (if in debug mode), or of the call and its parameters (if in trace mode).
For instance:ObjectResponse response; public void setup() { // Preparation of the query objectResponse = myQueryType.getResponseBuilder() .withQueryResponseDef("{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 MyQueryType response = queryType.exec(objectResponse, "heroParam", heroParamValue, "skip", Boolean.FALSE); Character c = response.getHero(); ... }
- Parameters:
objectResponse
- The definition of the response format, that describes what the GraphQL server is expected to returnparamsAndValues
- 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
SubscriptionClient
that allows the caller to act on the subscribed subscription. - 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
-
getResponseBuilder
Get theBuilder
for a full request, as expected by the exec and execWithBindValues methods.- Returns:
- Throws:
GraphQLRequestPreparationException
-
getGraphQLRequest
public GraphQLRequest getGraphQLRequest(String fullRequest) throws GraphQLRequestPreparationException Get theGraphQLRequest
for full request. For instance:GraphQLRequest request = new GraphQLRequest(fullRequest);
- Parameters:
fullRequest
- The full GraphQLRequest, as specified in the GraphQL specification- Returns:
- Throws:
GraphQLRequestPreparationException
-
subscribeToNewPostWithBindValues
public SubscriptionClient subscribeToNewPostWithBindValues(String queryResponseDef, SubscriptionCallback<Post> subscriptionCallback, String boardName, Map<String, Object> parameters) throws GraphQLRequestExecutionException, GraphQLRequestPreparationExceptionThis method registers a subscription, by executing a direct partial request against the GraphQL server. This subscription is one of the fields defined in the GraphQL subscription object. The queryResponseDef contains the part of the subscription that is after the subscription name (see the sample below), for instance "{id name}" if you want these two fields to be sent in the notifications you'll receive for this subscription.
You must also provide a callback instance of theSubscriptionCallback
, and the parameter for the subscription as parameter for this method. For instance, if the subscription subscribeToNewPost has one parameter boardName (as defined in the GraphQL schema):SubscriptionClient client; void setup() { subscriptionType = new SubscriptionType("http://localhost:8180/graphql/subscription"); } void exec() { Map<String, Object> params = new HashMap<>(); params.put("anOptionalParam", "a param value"); // PostSubscriptionCallback implement SubscriptionCallback
, as Post is the returned type for the // subscribeToNewPost subscription. Its onMessage(T) method will be called for each notification of this // subscription. client = subscriptionType.subscribeToNewPost( "{id date author publiclyAvailable title(param: ?anOptionalParam) content}", new PostSubscriptionCallback(), "Board name 1", // The parameter(s) of the subscription if any, are // directly sent as parameter for this method params // The bind variable you defined in your query are in this map. ); } void freeResources() { client.unsubscribe(); } - Parameters:
queryResponseDef
- The response definition of the subscription, in the native GraphQL format (see here above)subscriptionCallback
- An instance of SubscriptionCallback. Its SubscriptionCallback.onMessage(Object)
will be called for each notification received from this subscription.boardName
- Parameter for the subscribeToNewPost field of Subscription, as defined in the GraphQL schemaparameters
- The list of values, for the bind variables defined in the subscription. If there is no bind variable in the defined subscription, this argument may be null or an emptyMap
- Throws:
GraphQLRequestPreparationException
- When an error occurs during the request preparation, typically when building theObjectResponse
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
-
subscribeToNewPost
public SubscriptionClient subscribeToNewPost(String queryResponseDef, SubscriptionCallback<Post> subscriptionCallback, String boardName, Object... paramsAndValues) throws GraphQLRequestExecutionException, GraphQLRequestPreparationException This method registers a subscription, by executing a direct partial request against the GraphQL server. This subscription is one of the fields defined in the GraphQL subscription object. The queryResponseDef contains the part of the subscription that is after the subscription name (see the sample below), for instance "{id name}" if you want these two fields to be sent in the notifications you'll receive for this subscription.
You must also provide a callback instance of theSubscriptionCallback
, and the parameter for the subscription as parameter for this method. For instance, if the subscription subscribeToNewPost has one parameter boardName (as defined in the GraphQL schema):SubscriptionClient client; void setup() { subscriptionType = new SubscriptionType("http://localhost:8180/graphql/subscription"); } void exec() { // PostSubscriptionCallback implement SubscriptionCallback
, as Post is the returned type for the // subscribeToNewPost subscription. Its onMessage(T) method will be called for each notification of this // subscription. client = subscriptionType.subscribeToNewPost( "{id date author publiclyAvailable title(param: ?anOptionalParam) content}", new PostSubscriptionCallback(), "Board name 1", // The parameter(s) of the subscription if any, are // directly sent as parameter for this method "anOptionalParam", "a param value" // The bind variables that you've defined in your query are given // as a listof couple of (name, value) ); } void freeResources() { client.unsubscribe(); } - Parameters:
queryResponseDef
- The response definition of the subscription, in the native GraphQL format (see here above)subscriptionCallback
- An instance of SubscriptionCallback. Its SubscriptionCallback.onMessage(Object)
will be called for each notification received from this subscription.boardName
- Parameter for the subscribeToNewPost field of Subscription, as defined in the GraphQL schemaparameters
- The list of values, for the bind variables defined in the subscription. If there is no bind variable in the defined subscription, this argument may be null or an emptyMap
- Throws:
GraphQLRequestPreparationException
- When an error occurs during the request preparation, typically when building theObjectResponse
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
-
subscribeToNewPostWithBindValues
public SubscriptionClient subscribeToNewPostWithBindValues(ObjectResponse objectResponse, SubscriptionCallback<Post> subscriptionCallback, String boardName, Map<String, Object> parameters) throws GraphQLRequestExecutionExceptionThis method registers a subscription, by executing a direct partial request against the GraphQL server. This subscription is one of the fields defined in the GraphQL subscription object. The queryResponseDef contains the part of the subscription that is after the subscription name (see the sample below), for instance "{id name}" if you want these two fields to be sent in the notifications you'll receive for this subscription.
You must also provide a callback instance of theSubscriptionCallback
, and the parameter for the subscription as parameter for this method. For instance, if the subscription subscribeToNewPost has one parameter boardName (as defined in the GraphQL schema):SubscriptionClient client; GraphQLRequest subscriptionRequest; void setup() { subscriptionType = new SubscriptionType("http://localhost:8180/graphql/subscription"); subscriptionRequest = subscriptionType.getSubscribeToNewPostGraphQLRequest( "{id date author publiclyAvailable title(param: ?anOptionalParam) content}"); } void exec() { Map<String, Object> params = new HashMap<>(); params.put("anOptionalParam", "a param value"); // PostSubscriptionCallback implement SubscriptionCallback
, as Post is the returned type for the // subscribeToNewPost subscription. Its onMessage(T) method will be called for each notification of this // subscription. client = subscriptionType.subscribeToNewPost(subscriptionRequest, new PostSubscriptionCallback(), "Board name 1", // The parameter(s) of the subscription if any, are directly sent as parameter for // this method params // The bind variable you defined in your query are in this map. ); } void freeResources() { client.unsubscribe(); } - Parameters:
objectResponse
- The definition of the response format, that describes what the GraphQL server is expected to returnsubscriptionCallback
- An instance of SubscriptionCallback. Its SubscriptionCallback.onMessage(Object)
will be called for each notification received from this subscription.boardName
- Parameter for the subscribeToNewPost field of Subscription, as defined in the GraphQL schemaparameters
- The list of values, for the bind variables defined in the subscription. 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
-
subscribeToNewPost
public SubscriptionClient subscribeToNewPost(ObjectResponse objectResponse, SubscriptionCallback<Post> subscriptionCallback, String boardName, Object... paramsAndValues) throws GraphQLRequestExecutionException This method registers a subscription, by executing a direct partial request against the GraphQL server. This subscription is one of the fields defined in the GraphQL subscription object. The queryResponseDef contains the part of the subscription that is after the subscription name (see the sample below), for instance "{id name}" if you want these two fields to be sent in the notifications you'll receive for this subscription.
You must also provide a callback instance of theSubscriptionCallback
, and the parameter for the subscription as parameter for this method. For instance, if the subscription subscribeToNewPost has one parameter boardName (as defined in the GraphQL schema):SubscriptionClient client; GraphQLRequest subscriptionRequest; void setup() { subscriptionType = new SubscriptionType("http://localhost:8180/graphql/subscription"); subscriptionRequest = subscriptionType.getSubscribeToNewPostGraphQLRequest( "{id date author publiclyAvailable title(param: ?anOptionalParam) content}"); } void exec() { Map<String, Object> params = new HashMap<>(); params.put("anOptionalParam", "a param value"); // PostSubscriptionCallback implement SubscriptionCallback
, as Post is the returned type for the // subscribeToNewPost subscription. Its onMessage(T) method will be called for each notification of this // subscription. client = subscriptionType.subscribeToNewPost(subscriptionRequest, new PostSubscriptionCallback(), "Board name 1", // The parameter(s) of the subscription if any, are directly sent as parameter for // this method "anOptionalParam", "a param value" // The bind variables that you've defined in your query are given // as a listof couple of (name, value) ); } void freeResources() { client.unsubscribe(); } - Parameters:
objectResponse
- The definition of the response format, that describes what the GraphQL server is expected to returnsubscriptionCallback
- An instance of SubscriptionCallback. Its SubscriptionCallback.onMessage(Object)
will be called for each notification received from this subscription.boardName
- Parameter for the subscribeToNewPost field of Subscription, as defined in the GraphQL schemaparamsAndValues
- 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
-
getSubscribeToNewPostResponseBuilder
Get theBuilder
for the Post, as expected by the subscribeToNewPost subscription.- Returns:
- Throws:
GraphQLRequestPreparationException
-
getSubscribeToNewPostGraphQLRequest
public GraphQLRequest getSubscribeToNewPostGraphQLRequest(String partialRequest) throws GraphQLRequestPreparationException Get theGraphQLRequest
for the subscribeToNewPost executor, created with the given Partial request.- Parameters:
partialRequest
- The Partial GraphQLRequest, as explained in the plugin client documentation- Returns:
- Throws:
GraphQLRequestPreparationException
-