GraphQLException and GraphQLError
A GraphQLException
is a list of GraphQLError
s.
You can view the GraphQLError
definition in the following code section:
/// An error that may occur during the execution of a GraphQL query.
///
/// This will almost always be passed to a [GraphQLException].
class GraphQLError implements Exception, GraphQLException {
/// The reason execution was halted, whether it is a syntax error,
/// or a runtime error, or some other exception.
final String message;
/// An optional list of locations within the source text where
/// this error occurred.
///
/// Smart tools can use this information to show end users exactly
/// which part of the errant query
/// triggered an error.
final List<GraphQLErrorLocation> locations;
/// List of field names with aliased names or 0‐indexed integers for list
final List<Object>? path;
/// The stack trace of the [sourceError]
final StackTrace? stackTrace;
/// An optional error Object to pass more information of the
/// source of the problem for logging or other purposes
final Object? sourceError;
/// Extensions return to the client
///
/// This could be used to send more
/// information about the error, such as a specific error code.
final Map<String, Object?>? extensions;
/// An error that may occur during the execution of a GraphQL query.
///
/// This will almost always be passed to a [GraphQLException].
GraphQLError(
this.message, {
this.locations = const [],
this.path,
this.extensions,
StackTrace? stackTrace,
this.sourceError,
}) : stackTrace = stackTrace ?? StackTrace.current;