graphql

package module
v0.0.0-...-08ddf37 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2017 License: ISC Imports: 1 Imported by: 7

README

graphql

utilities for dealing with GraphQL queries in Go.

This package focuses on actually creating GraphQL servers and expects you to describe your schema directly in Go.

To that end this library initially has not emphasized GraphQL schema definition parsing and instead focuses on Query Documents and writing real servers.

license: ISC

version: Based on October2015 GraphQL Specification

status: unstable

contributions: encouraged

hacking

  • go generate ./...
  • go test ./...

Documentation

Overview

Package graphql provides utilties to deal with graphql calls

Limitations:

  • Variables with properties are not supported (example: $user.id)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Argument

type Argument struct {
	Name  string
	Value interface{}
}

Argument is an argument to a Field Call.

type ArgumentDefinition

type ArgumentDefinition struct {
	Name         string
	Type         Type
	DefaultValue *Value `json:",omitempty"`
}

ArgumentDefinition defines an argument for a field on a type.

type Arguments

type Arguments []Argument

Arguments is a collection of Argument values

func (Arguments) Get

func (a Arguments) Get(name string) (interface{}, bool)

Get is a helper to fetch a particular argument by name.

type Directive

type Directive struct {
	Name  string
	Type  *Type  `json:",omitempty"`
	Value *Value `json:",omitempty"`
}

Directive describes a directive which can alter behavior in different parts of a GraphQL Operation.

type Document

type Document struct {
	Operations          []Operation
	FragmentDefinitions []FragmentDefinition `json:",omitempty"`
	EnumDefinitions     []EnumDefinition     `json:",omitempty"`
	TypeDefinitions     []TypeDefinition     `json:",omitempty"`
	TypeExtensions      []TypeExtension      `json:",omitempty"`
}

Document is the top-level representation of a string in GraphQL.

type EnumDefinition

type EnumDefinition struct {
	Name   string
	Values []string
}

EnumDefinition defines an enum.

type EnumValue

type EnumValue struct {
	EnumTypeName string
	Value        string
}

EnumValue describes a possible value for an enum.

type Field

type Field struct {
	Name         string       `json:",omitempty"`
	Arguments    Arguments    `json:",omitempty"`
	SelectionSet SelectionSet `json:",omitempty"`
	Alias        string       `json:",omitempty"`
	Directives   []Directive  `json:",omitempty"`
}

A Field is one of the most important concepts in GraphQL. Fields specify what parts of data you would like to select.

type FieldDefinition

type FieldDefinition struct {
	Name                string
	Type                Type
	ArgumentDefinitions []ArgumentDefinition `json:",omitempty"`
}

FieldDefinition defines a fields on a type.

type FragmentDefinition

type FragmentDefinition struct {
	Name          string
	TypeCondition string
	SelectionSet  SelectionSet
	Directives    []Directive `json:",omitempty"`
}

FragmentDefinition defines a Query Fragment

type FragmentSpread

type FragmentSpread struct {
	Name       string      `json:",omitempty"`
	Directives []Directive `json:",omitempty"`
}

FragmentSpread is a reference to a QueryFragment elsewhere in an Operation.

type InlineFragment

type InlineFragment struct {
	TypeCondition string      `json:",omitempty"`
	Directives    []Directive `json:",omitempty"`
	SelectionSet  SelectionSet
}

InlineFragment is used in-line to apply a type condition within a selection.

type Interface

type Interface struct{}

Interface descibes a set of methods a type must conform to to satisfy it. TODO

type Operation

type Operation struct {
	Type                OperationType        `json:",omitempty"`
	Name                string               `json:",omitempty"`
	SelectionSet        SelectionSet         `json:",omitempty"`
	VariableDefinitions []VariableDefinition `json:",omitempty"`
	Directives          []Directive          `json:",omitempty"`
}

Operation is either a read or mutation in GraphQL.

func (*Operation) String

func (o *Operation) String() string

type OperationType

type OperationType string

OperationType is either "query" or "mutation" Queries are reads and mutations cause side-effects.

const (
	// OperationQuery is a read operation.
	OperationQuery OperationType = "query"
	// OperationMutation is a mutation.
	OperationMutation OperationType = "mutation"
)

type Selection

type Selection struct {
	Field          *Field          `json:",omitempty"`
	FragmentSpread *FragmentSpread `json:",omitempty"`
	InlineFragment *InlineFragment `json:",omitempty"`
}

A Selection is either a Field, a FragmentSpread, or an InlineFragment

func (*Selection) String

func (s *Selection) String() string

type SelectionSet

type SelectionSet []Selection

SelectionSet is a collection of Selection

type Type

type Type struct {
	Name     string
	Optional bool
	Params   []Type `json:",omitempty"`
}

Type describes an argument's type.

type TypeDefinition

type TypeDefinition struct {
	Name             string
	Interfaces       []Interface `json:",omitempty"`
	FieldDefinitions []FieldDefinition
}

TypeDefinition defines a type.

type TypeExtension

type TypeExtension struct {
	Name             string
	Interfaces       []Interface `json:",omitempty"`
	FieldDefinitions []FieldDefinition
}

TypeExtension extends an existing type.

type Value

type Value interface{}

Value refers to a value

type Variable

type Variable struct {
	Name              string
	PropertySelection *Variable `json:",omitempty"`
}

Variable describes a reference to a variable.

type VariableDefinition

type VariableDefinition struct {
	Variable     Variable
	Type         Type
	DefaultValue *Value `json:",omitempty"`
}

VariableDefinition defines a variable for an Operation.

Directories

Path Synopsis
Package example contains usage examples.
Package example contains usage examples.
basic_graphql_server
Program basic_graphql_server shows a simple HTTP server that exposes a bare schema.
Program basic_graphql_server shows a simple HTTP server that exposes a bare schema.
Package executor produces results from a graphql Operation and Schema.
Package executor produces results from a graphql Operation and Schema.
resolver
Package resolver exposes the Resolver interface
Package resolver exposes the Resolver interface
tracer
Package tracer provides an interface to attach execution metadata to a context.
Package tracer provides an interface to attach execution metadata to a context.
Package handler implements an HTTP interface to a Schema.
Package handler implements an HTTP interface to a Schema.
internal
Package parser implements an experimental parser for a subset of graphql.
Package parser implements an experimental parser for a subset of graphql.
Package schema provides the ability to register objects to be exposed via a graphql api.
Package schema provides the ability to register objects to be exposed via a graphql api.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL