graphql-0.7.0.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

type Alias = Name Source #

Alternative field name.

{
  smallPic: profilePic(size: 64)
  bigPic: profilePic(size: 1024)
}

Here "smallPic" and "bigPic" are aliases for the same field, "profilePic", used to distinquish between profile pictures with different arguments (sizes).

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 Value 
Instances
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".

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) 

data Directive Source #

Directive.

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

Constructors

Directive Name [Argument] 
Instances
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 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.

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 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".

type Name = Text Source #

Name.

type NamedType = Name Source #

Represents type names.

data NonNullType Source #

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

data ObjectField Source #

Key-value pair.

A list of ObjectFields represents a GraphQL object type.

Constructors

ObjectField Name Value 

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.

Currently only queries and mutations are supported.

Constructors

Query 
Mutation 

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 Selection Source #

Selection is a single entry in a selection set. It can be a single field, fragment spread or inline fragment.

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
  }
}

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
}

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

{
  user {
    ... on UserType {
      id
      name
    }
}
Instances
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
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) 

data Value Source #

Input value.

Instances
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 #