Safe Haskell | None |
---|---|
Language | Haskell2010 |
GraphQL output.
How we encode GraphQL responses.
- data Response
- type Errors = NonEmpty Error
- data Error = Error Text [Location]
- class GraphQLError e where
- singleError :: GraphQLError e => e -> Errors
Documentation
GraphQL response.
A GraphQL response must:
- be a map
- have a "data" key iff the operation executed
- have an "errors" key iff the operation encountered errors
- not include "data" if operation failed before execution (e.g. syntax errors, validation errors, missing info)
- not have keys other than "data", "errors", and "extensions"
Other interesting things:
- Doesn't have to be JSON, but does have to have maps, strings, lists, and null
- Can also support bool, int, enum, and float
- Value of "extensions" must be a map
"data" must be null if an error was encountered during execution that prevented a valid response.
"errors"
- must be a non-empty list
- each error is a map with "message", optionally "locations" key with list of locations
- locations are maps with 1-indexed "line" and "column" keys.
class GraphQLError e where Source #
An error that arises while processing a GraphQL query.
formatError :: e -> Text Source #
Represent an error as human-readable text, primarily intended for developers of GraphQL clients, and secondarily for developers of GraphQL servers.
toError :: e -> Error Source #
Represent an error as human-readable text, together with reference to a
series of locations within a GraphQL query document. Default
implementation calls formatError
and provides no locations.
singleError :: GraphQLError e => e -> Errors Source #
Make a list of errors containing a single error.