Class GraphQL
schema
and the execution strategy
Building this object is very cheap and can be done on each execution if necessary. Building the schema is often not
as cheap, especially if it's parsed from graphql IDL schema format via SchemaParser.
The data for a query is returned via ExecutionResult.getData() and any errors encountered as placed in
ExecutionResult.getErrors().
Runtime Exceptions
Runtime exceptions can be thrown by the graphql engine if certain situations are encountered. These are not errors in execution but rather totally unacceptable conditions in which to execute a graphql query.
CoercingSerializeException- is thrown when a value cannot be serialised by a Scalar type, for example a String value being coerced as an Int.UnresolvedTypeException- is thrown if aTypeResolverfails to provide a concrete object type given an interface or union type.InvalidSchemaException- is thrown if the schema is not valid when built viaGraphQLSchema.Builder.build()GraphQLException- is thrown as a general purpose runtime exception, for example if the code cant access a named field when examining a POJO.AssertException- is thrown as a low level code assertion exception for truly unexpected code conditions
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionexecute(ExecutionInput executionInput) Executes the graphql query using the provided input objectexecute(ExecutionInput.Builder executionInputBuilder) Executes the graphql query using the provided input object builderExecutes the specified graphql query/mutation/subscriptionexecute(UnaryOperator<ExecutionInput.Builder> builderFunction) Executes the graphql query using calling the builder function and giving it a new builder.executeAsync(ExecutionInput executionInput) Executes the graphql query using the provided input objectexecuteAsync(ExecutionInput.Builder executionInputBuilder) Executes the graphql query using the provided input object builderexecuteAsync(UnaryOperator<ExecutionInput.Builder> builderFunction) Executes the graphql query using the provided input object builderbooleanstatic GraphQL.BuildernewGraphQL(GraphQLSchema graphQLSchema) Helps you build a GraphQL object ready to execute queriestransform(Consumer<GraphQL.Builder> builderConsumer) This helps you transform the current GraphQL object into another one by starting a builder with all the current values and allows you to transform it how you want.static GraphQLUnusualConfigurationThis allows you to control "unusual" aspects of the GraphQL system including some JVM wide settingsunusualConfiguration(ExecutionInput executionInput) This allows you to control "unusual" per execution aspects of the GraphQL systemunusualConfiguration(ExecutionInput.Builder executionInputBuilder) This allows you to control "unusual" per execution aspects of the GraphQL systemunusualConfiguration(GraphQLContext graphQLContext) This allows you to control "unusual" per execution aspects of the GraphQL systemunusualConfiguration(GraphQLContext.Builder graphQLContextBuilder) This allows you to control "unusual" per execution aspects of the GraphQL system
-
Method Details
-
unusualConfiguration
This allows you to control "unusual" aspects of the GraphQL system including some JVM wide settingsThis is named unusual because in general we don't expect you to have to make ths configuration by default, but you can opt into certain features or disable them if you want to.
- Returns:
- a
GraphQLUnusualConfigurationobject
-
unusualConfiguration
public static GraphQLUnusualConfiguration.GraphQLContextConfiguration unusualConfiguration(ExecutionInput executionInput) This allows you to control "unusual" per execution aspects of the GraphQL systemThis is named unusual because in general we don't expect you to have to make ths configuration by default, but you can opt into certain features or disable them if you want to.
- Returns:
- a
GraphQLUnusualConfiguration.GraphQLContextConfigurationobject
-
unusualConfiguration
public static GraphQLUnusualConfiguration.GraphQLContextConfiguration unusualConfiguration(ExecutionInput.Builder executionInputBuilder) This allows you to control "unusual" per execution aspects of the GraphQL systemThis is named unusual because in general we don't expect you to have to make ths configuration by default, but you can opt into certain features or disable them if you want to.
- Returns:
- a
GraphQLUnusualConfiguration.GraphQLContextConfigurationobject
-
unusualConfiguration
public static GraphQLUnusualConfiguration.GraphQLContextConfiguration unusualConfiguration(GraphQLContext graphQLContext) This allows you to control "unusual" per execution aspects of the GraphQL systemThis is named unusual because in general we don't expect you to have to make ths configuration by default, but you can opt into certain features or disable them if you want to.
- Returns:
- a
GraphQLUnusualConfiguration.GraphQLContextConfigurationobject
-
unusualConfiguration
public static GraphQLUnusualConfiguration.GraphQLContextConfiguration unusualConfiguration(GraphQLContext.Builder graphQLContextBuilder) This allows you to control "unusual" per execution aspects of the GraphQL systemThis is named unusual because in general we don't expect you to have to make ths configuration by default, but you can opt into certain features or disable them if you want to.
- Returns:
- a
GraphQLUnusualConfiguration.GraphQLContextConfigurationobject
-
getGraphQLSchema
- Returns:
- the schema backing this
GraphQLinstance
-
getQueryStrategy
- Returns:
- the execution strategy used for queries in this
GraphQLinstance
-
getMutationStrategy
- Returns:
- the execution strategy used for mutation in this
GraphQLinstance
-
getSubscriptionStrategy
- Returns:
- the execution strategy used for subscriptions in this
GraphQLinstance
-
getIdProvider
- Returns:
- the provider of execution ids for this
GraphQLinstance
-
getInstrumentation
- Returns:
- the Instrumentation for this
GraphQLinstance, if any
-
isDoNotAutomaticallyDispatchDataLoader
public boolean isDoNotAutomaticallyDispatchDataLoader() -
getPreparsedDocumentProvider
- Returns:
- the PreparsedDocumentProvider for this
GraphQLinstance
-
getValueUnboxer
- Returns:
- the ValueUnboxer for this
GraphQLinstance
-
newGraphQL
Helps you build a GraphQL object ready to execute queries- Parameters:
graphQLSchema- the schema to use- Returns:
- a builder of GraphQL objects
-
transform
This helps you transform the current GraphQL object into another one by starting a builder with all the current values and allows you to transform it how you want.- Parameters:
builderConsumer- the consumer code that will be given a builder to transform- Returns:
- a new GraphQL object based on calling build on that builder
-
execute
Executes the specified graphql query/mutation/subscription- Parameters:
query- the query/mutation/subscription- Returns:
- an
ExecutionResultwhich can include errors
-
execute
Executes the graphql query using the provided input object builder- Parameters:
executionInputBuilder-ExecutionInput.Builder- Returns:
- an
ExecutionResultwhich can include errors
-
execute
Executes the graphql query using calling the builder function and giving it a new builder.This allows a lambda style like :
ExecutionResult result = graphql.execute(input -> input.query("{hello}").root(startingObj).context(contextObj));- Parameters:
builderFunction- a function that is given aExecutionInput.Builder- Returns:
- an
ExecutionResultwhich can include errors
-
execute
Executes the graphql query using the provided input object- Parameters:
executionInput-ExecutionInput- Returns:
- an
ExecutionResultwhich can include errors
-
executeAsync
public CompletableFuture<ExecutionResult> executeAsync(ExecutionInput.Builder executionInputBuilder) Executes the graphql query using the provided input object builderThis will return a promise (aka
CompletableFuture) to provide aExecutionResultwhich is the result of executing the provided query.- Parameters:
executionInputBuilder-ExecutionInput.Builder- Returns:
- a promise to an
ExecutionResultwhich can include errors
-
executeAsync
public CompletableFuture<ExecutionResult> executeAsync(UnaryOperator<ExecutionInput.Builder> builderFunction) Executes the graphql query using the provided input object builderThis will return a promise (aka
CompletableFuture) to provide aExecutionResultwhich is the result of executing the provided query.This allows a lambda style like :
ExecutionResult result = graphql.execute(input -> input.query("{hello}").root(startingObj).context(contextObj));- Parameters:
builderFunction- a function that is given aExecutionInput.Builder- Returns:
- a promise to an
ExecutionResultwhich can include errors
-
executeAsync
Executes the graphql query using the provided input objectThis will return a promise (aka
CompletableFuture) to provide aExecutionResultwhich is the result of executing the provided query.- Parameters:
executionInput-ExecutionInput- Returns:
- a promise to an
ExecutionResultwhich can include errors
-