Class Builder
java.lang.Object
com.graphql_java_generator.client.request.Builder
public class Builder
extends java.lang.Object
This builder is provided for compatibility of existing code, that would have been developed before the 1.6 release.
It allows to create
ObjectResponse, that will define the content of the GraphQL request toward the server.- Author:
- etienne-sf
-
Constructor Summary
Constructors Constructor Description Builder(java.lang.Class<? extends AbstractGraphQLRequest> graphQLRequestClass)This Builder allows to build a Full request, that is request as you can execute in the graphiql interface.Builder(java.lang.Class<? extends AbstractGraphQLRequest> graphQLRequestClass, java.lang.String fieldName, RequestType requestType, InputParameter... inputParams)This Builder allows to build a Partial request, that is a request for only one query/mutation/subscription. -
Method Summary
Modifier and Type Method Description ObjectResponsebuild()Returns the builtObjectResponse.BuilderwithQueryResponseDef(java.lang.String queryResponseDef)Builds aObjectResponsefrom a part of a GraphQL query.
-
Constructor Details
-
Builder
This Builder allows to build a Full request, that is request as you can execute in the graphiql interface.
When calling thewithQueryResponseDef(String), a newAbstractGraphQLRequestis created by calling itsAbstractGraphQLRequest(String)constructor.- Parameters:
graphQLRequestClass- The graphQLRequestClass inherits fromAbstractGraphQLRequest, and contains the generated context that allows proper GraphQL request executions
-
Builder
public Builder(java.lang.Class<? extends AbstractGraphQLRequest> graphQLRequestClass, java.lang.String fieldName, RequestType requestType, InputParameter... inputParams)This Builder allows to build a Partial request, that is a request for only one query/mutation/subscription.
When calling thewithQueryResponseDef(String), the query request can be something like the one below, based on the hero query of the star wars schema:{id appearsIn friends {name friends {friends{id name appearsIn}}}}This defines only the part of the GraphQL request that defines the expected response content from the GraphQL server.- Parameters:
graphQLRequestClass- The graphQLRequestClass inherits fromAbstractGraphQLRequest, and contains the generated context that allows proper GraphQL request executionsfieldName- The query/mutation/subscription name, as defined in the GraphQL schemarequestType- The request type allows to search fieldName in the query or in the mutation or the subscriptioninputParams- The input parameters for this query/mutation/subscription
-
-
Method Details
-
withQueryResponseDef
public Builder withQueryResponseDef(java.lang.String queryResponseDef) throws GraphQLRequestPreparationExceptionBuilds aObjectResponsefrom a part of a GraphQL query. This part define what's expected as a response for the field of the currentObjectResponsefor this builder.- Parameters:
queryResponseDef- A part of a response, for instance (for the hero query of the Star Wars GraphQL schema): "{ id name friends{name}}"
No special character are allowed (linefeed...).
This parameter can be a null or an empty string. In this case, all scalar fields are added.episode-- Returns:
- Throws:
GraphQLRequestPreparationException
-
build
Returns the builtObjectResponse. If no field (either scalar or suboject) has been added, then all scalar fields are added.- Returns:
- Throws:
GraphQLRequestPreparationException
-