graphql-1.0.2.0: Haskell GraphQL implementation
Safe HaskellSafe
LanguageHaskell2010

Language.GraphQL.AST.Document

Description

This module defines an abstract syntax tree for the GraphQL language. It follows closely the structure given in the specification. Please refer to Facebook's GraphQL Specification. for more information.

Synopsis

Documentation

data Argument Source #

Single argument.

{
  user(id: 4) {
    name
  }
}

Here "id" is an argument for the field "user" and its value is 4.

Constructors

Argument Name (Node Value) Location 

Instances

Instances details
Eq Argument Source # 
Instance details

Defined in Language.GraphQL.AST.Document

Show Argument Source # 
Instance details

Defined in Language.GraphQL.AST.Document

newtype ArgumentsDefinition Source #

A list of values passed to a field.

type Person {
  name: String
  picture(width: Int, height: Int): Url
}

Person has two fields, "name" and "picture". "name" doesn't have any arguments, so ArgumentsDefinition contains an empty list. "picture" contains definitions for 2 arguments: "width" and "height".

data Definition Source #

All kinds of definitions that can occur in a GraphQL document.

Instances

Instances details
Eq Definition Source # 
Instance details

Defined in Language.GraphQL.AST.Document

Show Definition Source # 
Instance details

Defined in Language.GraphQL.AST.Document

newtype Description Source #

GraphQL has built-in capability to document service APIs. Documentation is a GraphQL string that precedes a particular definition and contains Markdown. Any GraphQL definition can be documented this way.

"""
Supported languages.
"""
enum Language {
  English
  EN

  Russian
  RU
}

Constructors

Description (Maybe Text) 

Instances

Instances details
Eq Description Source # 
Instance details

Defined in Language.GraphQL.AST.Document

Show Description Source # 
Instance details

Defined in Language.GraphQL.AST.Document

data Directive Source #

Directive.

Directives begin with "@", can accept arguments, and can be applied to the most GraphQL elements, providing additional information.

Instances

Instances details
Eq Directive Source # 
Instance details

Defined in Language.GraphQL.AST.Document

Show Directive Source # 
Instance details

Defined in Language.GraphQL.AST.Document

type Document = NonEmpty Definition Source #

GraphQL document.

data EnumValueDefinition Source #

Single value in an enum definition.

enum Direction {
  NORTH
  EAST
  SOUTH
  WEST
}

"NORTH, EAST, SOUTH, and WEST are value definitions of an enum type definition Direction.

data Field Source #

The only required property of a field is its name. Optionally it can also have an alias, arguments, directives and a list of subfields.

In the following query "user" is a field with two subfields, "id" and "name":

{
  user {
    id
    name
  }
}

Instances

Instances details
Eq Field Source # 
Instance details

Defined in Language.GraphQL.AST.Document

Methods

(==) :: Field -> Field -> Bool #

(/=) :: Field -> Field -> Bool #

Show Field Source # 
Instance details

Defined in Language.GraphQL.AST.Document

Methods

showsPrec :: Int -> Field -> ShowS #

show :: Field -> String #

showList :: [Field] -> ShowS #

data FieldDefinition Source #

Definition of a single field in a type.

type Person {
  name: String
  picture(width: Int, height: Int): Url
}

"name" and "picture", including their arguments and types, are field definitions.

data FragmentSpread Source #

A fragment spread refers to a fragment defined outside the operation and is expanded at the execution time.

{
  user {
    ...userFragment
  }
}

fragment userFragment on UserType {
  id
  name
}

newtype ImplementsInterfaces t Source #

Defines a list of interfaces implemented by the given object type.

type Business implements NamedEntity & ValuedEntity {
  name: String
}

Here the object type Business implements two interfaces: NamedEntity and ValuedEntity.

data InlineFragment Source #

Inline fragments don't have any name and the type condition ("on UserType") is optional.

{
  user {
    ... on UserType {
      id
      name
    }
}

data InputValueDefinition Source #

Defines an input value.

  • Input values can define field arguments, see ArgumentsDefinition.
  • They can also be used as field definitions in an input type.
input Point2D {
  x: Float
  y: Float
}

The input type Point2D contains two value definitions: "x" and "y".

data Location Source #

Error location, line and column.

Constructors

Location 

Fields

Instances

Instances details
Eq Location Source # 
Instance details

Defined in Language.GraphQL.AST.Document

Ord Location Source # 
Instance details

Defined in Language.GraphQL.AST.Document

Show Location Source # 
Instance details

Defined in Language.GraphQL.AST.Document

type Name = Text Source #

Name.

type NamedType = Name Source #

Represents type names.

data Node a Source #

Contains some tree node with a location.

Constructors

Node 

Fields

Instances

Instances details
Functor Node Source # 
Instance details

Defined in Language.GraphQL.AST.Document

Methods

fmap :: (a -> b) -> Node a -> Node b #

(<$) :: a -> Node b -> Node a #

Eq a => Eq (Node a) Source # 
Instance details

Defined in Language.GraphQL.AST.Document

Methods

(==) :: Node a -> Node a -> Bool #

(/=) :: Node a -> Node a -> Bool #

Show a => Show (Node a) Source # 
Instance details

Defined in Language.GraphQL.AST.Document

Methods

showsPrec :: Int -> Node a -> ShowS #

show :: Node a -> String #

showList :: [Node a] -> ShowS #

data NonNullType Source #

Helper type to represent Non-Null types and lists of such types.

Instances

Instances details
Eq NonNullType Source # 
Instance details

Defined in Language.GraphQL.AST.Document

Show NonNullType Source # 
Instance details

Defined in Language.GraphQL.AST.Document

data ObjectField a Source #

Key-value pair.

A list of ObjectFields represents a GraphQL object type.

Constructors

ObjectField 

Fields

Instances

Instances details
Functor ObjectField Source # 
Instance details

Defined in Language.GraphQL.AST.Document

Methods

fmap :: (a -> b) -> ObjectField a -> ObjectField b #

(<$) :: a -> ObjectField b -> ObjectField a #

Eq a => Eq (ObjectField a) Source # 
Instance details

Defined in Language.GraphQL.AST.Document

Show a => Show (ObjectField a) Source # 
Instance details

Defined in Language.GraphQL.AST.Document

data OperationType Source #

GraphQL has 3 operation types:

  • query - a read-only fetch.
  • mutation - a write operation followed by a fetch.
  • subscription - a long-lived request that fetches data in response to source events.

Constructors

Query 
Mutation 
Subscription 

data OperationTypeDefinition Source #

Root operation type definition.

Defining root operation types is not required since they have defaults. So the default query root type is Query, and the default mutation root type is Mutation. But these defaults can be changed for a specific schema. In the following code the query root type is changed to MyQueryRootType, and the mutation root type to MyMutationRootType:

schema {
  query: MyQueryRootType
  mutation: MyMutationRootType
}

data SchemaExtension Source #

Extension of the schema definition by further operations or directives.

data Selection Source #

Selection is a single entry in a selection set. It can be a single Field, FragmentSpread or an InlineFragment.

Instances

Instances details
Eq Selection Source # 
Instance details

Defined in Language.GraphQL.AST.Document

Show Selection Source # 
Instance details

Defined in Language.GraphQL.AST.Document

type SelectionSet = NonEmpty Selection Source #

"Top-level" selection, selection on an operation or fragment.

type SelectionSetOpt = [Selection] Source #

Field selection.

data Type Source #

Type representation.

Instances

Instances details
Eq Type Source # 
Instance details

Defined in Language.GraphQL.AST.Document

Methods

(==) :: Type -> Type -> Bool #

(/=) :: Type -> Type -> Bool #

Show Type Source # 
Instance details

Defined in Language.GraphQL.AST.Document

Methods

showsPrec :: Int -> Type -> ShowS #

show :: Type -> String #

showList :: [Type] -> ShowS #

type TypeCondition = Name Source #

Type condition.

data TypeSystemDefinition Source #

Type system can define a schema, a type or a directive.

schema {
  query: Query
}

directive example on FIELD_DEFINITION

type Query {
  field: String example
}

This example defines a custom directive "@example", which is applied to a field definition of the type definition Query. On the top the schema is defined by taking advantage of the type Query.

data TypeSystemExtension Source #

Extension for a type system definition. Only schema and type definitions can be extended.

newtype UnionMemberTypes t Source #

List of types forming a union.

union SearchResult = Person | Photo

Person and Photo are member types of the union SearchResult.

Constructors

UnionMemberTypes (t NamedType) 

Instances

Instances details
Foldable t => Eq (UnionMemberTypes t) Source # 
Instance details

Defined in Language.GraphQL.AST.Document

Foldable t => Show (UnionMemberTypes t) Source # 
Instance details

Defined in Language.GraphQL.AST.Document

data Value Source #

Input value (literal or variable).

Instances

Instances details
Eq Value Source # 
Instance details

Defined in Language.GraphQL.AST.Document

Methods

(==) :: Value -> Value -> Bool #

(/=) :: Value -> Value -> Bool #

Show Value Source # 
Instance details

Defined in Language.GraphQL.AST.Document

Methods

showsPrec :: Int -> Value -> ShowS #

show :: Value -> String #

showList :: [Value] -> ShowS #

data VariableDefinition Source #

Variable definition.

Each operation can include a list of variables:

query (protagonist: String = "Zarathustra") {
  getAuthor(protagonist: $protagonist)
}

This query defines an optional variable protagonist of type String, its default value is "Zarathustra". If no default value is defined and no value is provided, a variable can still be null if its type is nullable.

Variables are usually passed along with the query, but not in the query itself. They make queries reusable.

escape :: Char -> String Source #

Escapes a single character according to the GraphQL escaping rules for double-quoted string values.

Characters, that should be escaped, are written as escaped characters with a backslash or Unicode with an "\u". Other characters are returned as strings.