Class Builder
java.lang.Object
com.graphql_java_generator.client.request.Builder
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
ConstructorsConstructorDescriptionBuilder
(org.springframework.graphql.client.GraphQlClient graphQlClient, Class<? extends AbstractGraphQLRequest> graphQLRequestClass) This Builder allows to build a Full request, that is request as you can execute in the graphiql interface.Builder
(org.springframework.graphql.client.GraphQlClient graphQlClient, Class<? extends AbstractGraphQLRequest> graphQLRequestClass, 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 TypeMethodDescriptionbuild()
Returns the builtObjectResponse
.withQueryResponseDef
(String queryResponseDef) Builds aObjectResponse
from a part of a GraphQL query.
-
Constructor Details
-
Builder
public Builder(org.springframework.graphql.client.GraphQlClient graphQlClient, Class<? extends AbstractGraphQLRequest> graphQLRequestClass) This Builder allows to build a Full request, that is request as you can execute in the graphiql interface.
When calling thewithQueryResponseDef(String)
, a newAbstractGraphQLRequest
is created by calling itsAbstractGraphQLRequest#AbstractGraphQLRequest(String)
constructor.- Parameters:
graphQLRequestClass
- The graphQLRequestClass inherits fromAbstractGraphQLRequest
, and contains the generated context that allows proper GraphQL request executions
-
Builder
public Builder(org.springframework.graphql.client.GraphQlClient graphQlClient, Class<? extends AbstractGraphQLRequest> graphQLRequestClass, 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(String queryResponseDef) throws GraphQLRequestPreparationException Builds aObjectResponse
from a part of a GraphQL query. This part define what's expected as a response for the field of the currentObjectResponse
for 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
-