Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Latest commit

 

History

History
84 lines (61 loc) · 1.44 KB

ast.md

File metadata and controls

84 lines (61 loc) · 1.44 KB

This document specifies the core AST node types that support the GraphQL grammar.

Node object

AST nodes are represented as Node objects, which may have any prototype inheritance but which implement the following interface:

interface Node {
  type: string;
}

The type field is a string representing the AST variant type. Each subtype of Node is documented below with the specific string of its type field. You can use this field to determine which interface a node implements.

Query

interface Query <: Node {
  type: "Query";
  fields: [ Field ];
}

A query source tree. It may also describe field fragments.

Field

interface Field <: Node {
  type: "Field";
  name: string;
  params: [ Argument ];
  fields: [ Field ];
}

A field declaration.

Argument

interface Argument <: Node {
  type: "Argument";
  name: string;
  value: [ Literal | Variable | Reference ];
}

A named argument.

Literal

interface Literal <: Node {
  type: "Literal";
  value: string | boolean | number | null;
}

A JSON literal token. See ECMA-404 specification.

Variable

interface Variable <: Node {
  type: "Variable";
  name: string;
}

A query variable.

Reference

interface Reference <: Node {
  type: "Reference";
  name: string;
}

A reference to a context value. Used for internal usage.