graphql-api-0.1.2: Sketch of GraphQL stuff

Safe HaskellNone



Implement the "Execution" part of the GraphQL spec.

Actually, most of the execution work takes place in Resolver, but there's still a fair bit required to glue together the results of Validation and the processing in Resolver. This module provides that glue.



type VariableValues = Map Variable Value Source #

A map of variables to their values.

In GraphQL the variable values are not part of the query itself, they are instead passed in through a separate channel. Create a VariableValues from this other channel and pass it to substituteVariables.

GraphQL allows the values of variables to be specified, but doesn't provide a way for doing so in the language.

data ExecutionError Source #

An error that occurs while executing a query. Technically, ResolverError also falls into the same category, but is separate to help our code be a bit better organized.

formatError :: GraphQLError e => e -> Text Source #

Represent an error as human-readable text, primarily intended for developers of GraphQL clients, and secondarily for developers of GraphQL servers.

getOperation :: QueryDocument value -> Maybe Name -> Either ExecutionError (Operation value) Source #

Get an operation from a GraphQL document

GetOperation(document, operationName):

  • If {operationName} is {null}:
  • If {document} contains exactly one operation.
  • Return the Operation contained in the {document}.
  • Otherwise produce a query error requiring {operationName}.
  • Otherwise:
  • Let {operation} be the Operation named {operationName} in {document}.
  • If {operation} was not found, produce a query error.
  • Return {operation}.

substituteVariables :: Operation VariableValue -> VariableValues -> Either ExecutionError (Operation Value) Source #

Substitute variables in a GraphQL document.

Once this is done, there will be no variables in the document whatsoever.