B - this base class allows you to derive new classes from this base error builder@PublicApi public class GraphqlErrorBuilder<B extends GraphqlErrorBuilder<B>> extends java.lang.Object implements GraphQLError.Builder<B>
GraphQLErrors and also has a quick way to make a DataFetcherResults
from that error.| Modifier | Constructor and Description |
|---|---|
protected |
GraphqlErrorBuilder() |
| Modifier and Type | Method and Description |
|---|---|
GraphQLError |
build() |
B |
errorType(ErrorClassification errorType)
Sets the
ErrorClassification of the message |
B |
extensions(@Nullable java.util.Map<java.lang.String,java.lang.Object> extensions)
Sets the extensions of the message
|
ErrorClassification |
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 error
|
B |
locations(@Nullable java.util.List<SourceLocation> locations)
This adds locations to the error
|
B |
message(java.lang.String message,
java.lang.Object... formatArgs)
Sets the message of the error using
String.format(String, Object...) with the arguments |
static GraphqlErrorBuilder<?> |
newError() |
static GraphqlErrorBuilder<?> |
newError(DataFetchingEnvironment dataFetchingEnvironment)
This will set up the
GraphQLError.getLocations() and GraphQLError.getPath() for you from the
fetching environment. |
B |
path(@Nullable java.util.List<java.lang.Object> path)
Sets the path of the message
|
B |
path(@Nullable ResultPath path)
Sets the path of the message
|
DataFetcherResult<?> |
toResult()
A helper method that allows you to return this error as a
DataFetcherResult |
public java.lang.String getMessage()
@Nullable public @Nullable java.util.List<java.lang.Object> getPath()
@Nullable public @Nullable java.util.List<SourceLocation> getLocations()
public ErrorClassification getErrorType()
@Nullable public @Nullable java.util.Map<java.lang.String,java.lang.Object> getExtensions()
public static GraphqlErrorBuilder<?> newError()
GraphQLErrorspublic static GraphqlErrorBuilder<?> newError(DataFetchingEnvironment dataFetchingEnvironment)
GraphQLError.getLocations() and GraphQLError.getPath() for you from the
fetching environment.dataFetchingEnvironment - the data fetching environmentGraphQLErrorspublic B message(java.lang.String message, java.lang.Object... formatArgs)
GraphQLError.BuilderString.format(String, Object...) with the argumentsmessage in interface GraphQLError.Builder<B extends GraphqlErrorBuilder<B>>message - the messageformatArgs - the arguments to usepublic B locations(@Nullable @Nullable java.util.List<SourceLocation> locations)
GraphQLError.Builderlocations in interface GraphQLError.Builder<B extends GraphqlErrorBuilder<B>>locations - the locations to addpublic B location(@Nullable @Nullable SourceLocation location)
GraphQLError.Builderlocation in interface GraphQLError.Builder<B extends GraphqlErrorBuilder<B>>location - the locations to addpublic B path(@Nullable @Nullable ResultPath path)
GraphQLError.Builderpath in interface GraphQLError.Builder<B extends GraphqlErrorBuilder<B>>path - can be nullpublic B path(@Nullable @Nullable java.util.List<java.lang.Object> path)
GraphQLError.Builderpath in interface GraphQLError.Builder<B extends GraphqlErrorBuilder<B>>path - can be nullpublic B errorType(ErrorClassification errorType)
GraphQLError.BuilderErrorClassification of the messageerrorType in interface GraphQLError.Builder<B extends GraphqlErrorBuilder<B>>errorType - the error classification to usepublic B extensions(@Nullable @Nullable java.util.Map<java.lang.String,java.lang.Object> extensions)
GraphQLError.Builderextensions in interface GraphQLError.Builder<B extends GraphqlErrorBuilder<B>>extensions - the extensions to usepublic GraphQLError build()
build in interface GraphQLError.Builder<B extends GraphqlErrorBuilder<B>>public DataFetcherResult<?> toResult()
DataFetcherResult