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 java.lang.Object implements GraphQLError.Builder<B>
This helps you buildGraphQLErrors and also has a quick way to make aDataFetcherResults from that error.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedGraphqlErrorBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description GraphQLErrorbuild()BerrorType(ErrorClassification errorType)Sets theErrorClassificationof the messageBextensions(@Nullable java.util.Map<java.lang.String,java.lang.Object> extensions)Sets the extensions of the messageErrorClassificationgetErrorType()@Nullable java.util.Map<java.lang.String,java.lang.Object>getExtensions()@Nullable java.util.List<SourceLocation>getLocations()java.lang.StringgetMessage()@Nullable java.util.List<java.lang.Object>getPath()Blocation(@Nullable SourceLocation location)This adds a location to the errorBlocations(@Nullable java.util.List<SourceLocation> locations)This adds locations to the errorBmessage(java.lang.String message, java.lang.Object... formatArgs)Sets 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.Bpath(@Nullable ResultPath path)Sets the path of the messageBpath(@Nullable java.util.List<java.lang.Object> path)Sets the path of the messageDataFetcherResult<?>toResult()A helper method that allows you to return this error as aDataFetcherResult
-
-
-
Method Detail
-
getMessage
public java.lang.String getMessage()
-
getPath
public @Nullable java.util.List<java.lang.Object> getPath()
-
getLocations
public @Nullable java.util.List<SourceLocation> getLocations()
-
getErrorType
public ErrorClassification getErrorType()
-
getExtensions
public @Nullable java.util.Map<java.lang.String,java.lang.Object> getExtensions()
-
newError
public static GraphqlErrorBuilder<?> newError()
- Returns:
- a builder of
GraphQLErrors
-
newError
public static GraphqlErrorBuilder<?> newError(DataFetchingEnvironment dataFetchingEnvironment)
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
public B message(java.lang.String message, java.lang.Object... formatArgs)
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
public B locations(@Nullable java.util.List<SourceLocation> 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
public B location(@Nullable SourceLocation 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
public B path(@Nullable ResultPath 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
public B path(@Nullable java.util.List<java.lang.Object> 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
public B errorType(ErrorClassification 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
public B extensions(@Nullable java.util.Map<java.lang.String,java.lang.Object> 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
public GraphQLError build()
- Specified by:
buildin interfaceGraphQLError.Builder<B extends GraphqlErrorBuilder<B>>- Returns:
- a newly built GraphqlError
-
toResult
public DataFetcherResult<?> toResult()
A helper method that allows you to return this error as aDataFetcherResult- Returns:
- a new data fetcher result that contains the built error
-
-