Package graphql
Class GraphqlErrorBuilder<B extends GraphqlErrorBuilder<B>>
java.lang.Object
graphql.GraphqlErrorBuilder<B>
- Type Parameters:
B- this base class allows you to derive new classes from this base error builder
- All Implemented Interfaces:
GraphQLError.Builder<B>
@PublicApi
public class GraphqlErrorBuilder<B extends GraphqlErrorBuilder<B>>
extends Object
implements GraphQLError.Builder<B>
This helps you build
GraphQLErrors and also has a quick way to make a DataFetcherResults
from that error.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()errorType(ErrorClassification errorType) Sets theErrorClassificationof the messageextensions(@Nullable Map<String, Object> extensions) Sets the extensions of the message@Nullable List<SourceLocation> getPath()location(@Nullable SourceLocation location) This adds a location to the errorlocations(@Nullable List<SourceLocation> locations) This adds locations to the errorSets the message of the error usingString.format(String, Object...)with the argumentsstatic GraphqlErrorBuilder<?> newError()static GraphqlErrorBuilder<?> newError(DataFetchingEnvironment dataFetchingEnvironment) This will set up theGraphQLError.getLocations()andGraphQLError.getPath()for you from the fetching environment.path(@Nullable ResultPath path) Sets the path of the messageSets the path of the messagetoResult()A helper method that allows you to return this error as aDataFetcherResult
-
Constructor Details
-
GraphqlErrorBuilder
protected GraphqlErrorBuilder()
-
-
Method Details
-
getMessage
-
getPath
-
getLocations
-
getErrorType
-
getExtensions
-
newError
- Returns:
- a builder of
GraphQLErrors
-
newError
This will set up theGraphQLError.getLocations()andGraphQLError.getPath()for you from the fetching environment.- Parameters:
dataFetchingEnvironment- the data fetching environment- Returns:
- a builder of
GraphQLErrors
-
message
Description copied from interface:GraphQLError.BuilderSets the message of the error usingString.format(String, Object...)with the arguments- Specified by:
messagein interfaceGraphQLError.Builder<B extends GraphqlErrorBuilder<B>>- Parameters:
message- the messageformatArgs- the arguments to use- Returns:
- this builder
-
locations
Description copied from interface:GraphQLError.BuilderThis adds locations to the error- Specified by:
locationsin interfaceGraphQLError.Builder<B extends GraphqlErrorBuilder<B>>- Parameters:
locations- the locations to add- Returns:
- this builder
-
location
Description copied from interface:GraphQLError.BuilderThis adds a location to the error- Specified by:
locationin interfaceGraphQLError.Builder<B extends GraphqlErrorBuilder<B>>- Parameters:
location- the locations to add- Returns:
- this builder
-
path
Description copied from interface:GraphQLError.BuilderSets the path of the message- Specified by:
pathin interfaceGraphQLError.Builder<B extends GraphqlErrorBuilder<B>>- Parameters:
path- can be null- Returns:
- this builder
-
path
Description copied from interface:GraphQLError.BuilderSets the path of the message- Specified by:
pathin interfaceGraphQLError.Builder<B extends GraphqlErrorBuilder<B>>- Parameters:
path- can be null- Returns:
- this builder
-
errorType
Description copied from interface:GraphQLError.BuilderSets theErrorClassificationof the message- Specified by:
errorTypein interfaceGraphQLError.Builder<B extends GraphqlErrorBuilder<B>>- Parameters:
errorType- the error classification to use- Returns:
- this builder
-
extensions
Description copied from interface:GraphQLError.BuilderSets the extensions of the message- Specified by:
extensionsin interfaceGraphQLError.Builder<B extends GraphqlErrorBuilder<B>>- Parameters:
extensions- the extensions to use- Returns:
- this builder
-
build
- Specified by:
buildin interfaceGraphQLError.Builder<B extends GraphqlErrorBuilder<B>>- Returns:
- a newly built GraphqlError
-
toResult
A helper method that allows you to return this error as aDataFetcherResult- Returns:
- a new data fetcher result that contains the built error
-