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 buildGraphQLError
s and also has a quick way to make aDataFetcherResult
s from that error.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
GraphqlErrorBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description GraphQLError
build()
B
errorType(ErrorClassification errorType)
Sets theErrorClassification
of the messageB
extensions(@Nullable java.util.Map<java.lang.String,java.lang.Object> extensions)
Sets the extensions of the messageErrorClassification
getErrorType()
@Nullable java.util.Map<java.lang.String,java.lang.Object>
getExtensions()
@Nullable java.util.List<SourceLocation>
getLocations()
java.lang.String
getMessage()
@Nullable java.util.List<java.lang.Object>
getPath()
B
location(@Nullable SourceLocation location)
This adds a location to the errorB
locations(@Nullable java.util.List<SourceLocation> locations)
This adds locations to the errorB
message(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.B
path(@Nullable ResultPath path)
Sets the path of the messageB
path(@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
@Nullable public @Nullable java.util.List<java.lang.Object> getPath()
-
getLocations
@Nullable public @Nullable java.util.List<SourceLocation> getLocations()
-
getErrorType
public ErrorClassification getErrorType()
-
getExtensions
@Nullable public @Nullable java.util.Map<java.lang.String,java.lang.Object> getExtensions()
-
newError
public static GraphqlErrorBuilder<?> newError()
- Returns:
- a builder of
GraphQLError
s
-
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
GraphQLError
s
-
message
public B message(java.lang.String message, java.lang.Object... formatArgs)
Description copied from interface:GraphQLError.Builder
Sets the message of the error usingString.format(String, Object...)
with the arguments- Specified by:
message
in interfaceGraphQLError.Builder<B extends GraphqlErrorBuilder<B>>
- Parameters:
message
- the messageformatArgs
- the arguments to use- Returns:
- this builder
-
locations
public B locations(@Nullable @Nullable java.util.List<SourceLocation> locations)
Description copied from interface:GraphQLError.Builder
This adds locations to the error- Specified by:
locations
in interfaceGraphQLError.Builder<B extends GraphqlErrorBuilder<B>>
- Parameters:
locations
- the locations to add- Returns:
- this builder
-
location
public B location(@Nullable @Nullable SourceLocation location)
Description copied from interface:GraphQLError.Builder
This adds a location to the error- Specified by:
location
in interfaceGraphQLError.Builder<B extends GraphqlErrorBuilder<B>>
- Parameters:
location
- the locations to add- Returns:
- this builder
-
path
public B path(@Nullable @Nullable ResultPath path)
Description copied from interface:GraphQLError.Builder
Sets the path of the message- Specified by:
path
in interfaceGraphQLError.Builder<B extends GraphqlErrorBuilder<B>>
- Parameters:
path
- can be null- Returns:
- this builder
-
path
public B path(@Nullable @Nullable java.util.List<java.lang.Object> path)
Description copied from interface:GraphQLError.Builder
Sets the path of the message- Specified by:
path
in 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.Builder
Sets theErrorClassification
of the message- Specified by:
errorType
in interfaceGraphQLError.Builder<B extends GraphqlErrorBuilder<B>>
- Parameters:
errorType
- the error classification to use- Returns:
- this builder
-
extensions
public B extensions(@Nullable @Nullable java.util.Map<java.lang.String,java.lang.Object> extensions)
Description copied from interface:GraphQLError.Builder
Sets the extensions of the message- Specified by:
extensions
in interfaceGraphQLError.Builder<B extends GraphqlErrorBuilder<B>>
- Parameters:
extensions
- the extensions to use- Returns:
- this builder
-
build
public GraphQLError build()
- Specified by:
build
in 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
-
-