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
GraphQLError
s and also has a quick way to make a DataFetcherResult
s
from that error.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
errorType
(ErrorClassification errorType) Sets theErrorClassification
of 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
GraphQLError
s
-
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
GraphQLError
s
-
message
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
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
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
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
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
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
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
- Specified by:
build
in 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
-