types

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: BSD-2-Clause Imports: 5 Imported by: 4

Documentation

Overview

Package types represents all types from the GraphQL specification in code.

The names of the Go types, whenever possible, match 1:1 with the names from the specification.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Argument

type Argument struct {
	Name  Ident
	Value Value
}

Argument is a representation of the GraphQL Argument.

https://spec.graphql.org/draft/#sec-Language.Arguments

type ArgumentList

type ArgumentList []*Argument

ArgumentList is a collection of GraphQL Arguments.

func (ArgumentList) Get

func (l ArgumentList) Get(name string) (Value, bool)

Returns a Value in the ArgumentList by name.

func (ArgumentList) MustGet

func (l ArgumentList) MustGet(name string) Value

MustGet returns a Value in the ArgumentList by name. MustGet will panic if the argument name is not found in the ArgumentList.

type ArgumentsDefinition

type ArgumentsDefinition []*InputValueDefinition

func (ArgumentsDefinition) Get

Get returns an InputValueDefinition in the ArgumentsDefinition by name or nil if not found.

type Directive

type Directive struct {
	Name      Ident
	Arguments ArgumentList
}

Directive is a representation of the GraphQL Directive.

http://spec.graphql.org/draft/#sec-Language.Directives

type DirectiveDefinition

type DirectiveDefinition struct {
	Name       string
	Desc       string
	Repeatable bool
	Locations  []string
	Arguments  ArgumentsDefinition
	Loc        errors.Location
}

DirectiveDefinition is a representation of the GraphQL DirectiveDefinition.

http://spec.graphql.org/draft/#sec-Type-System.Directives

type DirectiveFunc added in v0.0.9

type DirectiveFunc func(ctx context.Context, directive *Directive, input interface{}) (context.Context, error)

type DirectiveList

type DirectiveList []*Directive

func (DirectiveList) Get

func (l DirectiveList) Get(name string) *Directive

Returns the Directive in the DirectiveList by name or nil if not found.

type EnumTypeDefinition

type EnumTypeDefinition struct {
	Name                 string
	EnumValuesDefinition []*EnumValueDefinition
	Desc                 string
	Directives           DirectiveList
	Loc                  errors.Location
}

EnumTypeDefinition defines a set of possible enum values.

Like scalar types, an EnumTypeDefinition also represents a leaf value in a GraphQL type system.

http://spec.graphql.org/draft/#sec-Enums

func (*EnumTypeDefinition) Description

func (t *EnumTypeDefinition) Description() string

func (*EnumTypeDefinition) Kind

func (*EnumTypeDefinition) Kind() string

func (*EnumTypeDefinition) String

func (t *EnumTypeDefinition) String() string

func (*EnumTypeDefinition) TypeName

func (t *EnumTypeDefinition) TypeName() string

type EnumValueDefinition

type EnumValueDefinition struct {
	EnumValue  string
	Directives DirectiveList
	Desc       string
	Loc        errors.Location
}

EnumValueDefinition are unique values that may be serialized as a string: the name of the represented value.

http://spec.graphql.org/draft/#EnumValueDefinition

type ExecutableDefinition

type ExecutableDefinition struct {
	Operations OperationList
	Fragments  FragmentList
}

ExecutableDefinition represents a set of operations or fragments that can be executed against a schema.

http://spec.graphql.org/draft/#ExecutableDefinition

type Extension

type Extension struct {
	Type       NamedType
	Directives DirectiveList
	Loc        errors.Location
}

Extension type defines a GraphQL type extension. Schemas, Objects, Inputs and Scalars can be extended.

https://spec.graphql.org/draft/#sec-Type-System-Extensions

type Field

type Field struct {
	Alias           Ident
	Name            Ident
	Arguments       ArgumentList
	Directives      DirectiveList
	SelectionSet    SelectionSet
	SelectionSetLoc errors.Location
}

Field represents a field used in a query.

type FieldDefinition

type FieldDefinition struct {
	Name       string
	Arguments  ArgumentsDefinition
	Type       Type
	Directives DirectiveList
	Desc       string
	Loc        errors.Location
}

FieldDefinition is a representation of a GraphQL FieldDefinition.

http://spec.graphql.org/draft/#FieldDefinition

type FieldsDefinition

type FieldsDefinition []*FieldDefinition

FieldsDefinition is a list of an ObjectTypeDefinition's Fields.

https://spec.graphql.org/draft/#FieldsDefinition

func (FieldsDefinition) Get

Get returns a FieldDefinition in a FieldsDefinition by name or nil if not found.

func (FieldsDefinition) Names

func (l FieldsDefinition) Names() []string

Names returns a slice of FieldDefinition names.

type Fragment

type Fragment struct {
	On         TypeName
	Selections SelectionSet
}

type FragmentDefinition

type FragmentDefinition struct {
	Fragment
	Name       Ident
	Directives DirectiveList
	Loc        errors.Location
}

FragmentDefinition is a representation of the GraphQL FragmentDefinition.

http://spec.graphql.org/draft/#FragmentDefinition

type FragmentList

type FragmentList []*FragmentDefinition

func (FragmentList) Get

func (l FragmentList) Get(name string) *FragmentDefinition

Returns a FragmentDefinition by name or nil if not found.

type FragmentSpread

type FragmentSpread struct {
	Name       Ident
	Directives DirectiveList
	Loc        errors.Location
}

FragmentSpread is a representation of the GraphQL FragmentSpread.

http://spec.graphql.org/draft/#FragmentSpread

type Ident

type Ident struct {
	Name string
	Loc  errors.Location
}

type InlineFragment

type InlineFragment struct {
	Fragment
	Directives DirectiveList
	Loc        errors.Location
}

InlineFragment is a representation of the GraphQL InlineFragment.

http://spec.graphql.org/draft/#InlineFragment

type InputObject

type InputObject struct {
	Name       string
	Desc       string
	Values     ArgumentsDefinition
	Directives DirectiveList
	Loc        errors.Location
}

InputObject types define a set of input fields; the input fields are either scalars, enums, or other input objects.

This allows arguments to accept arbitrarily complex structs.

http://spec.graphql.org/draft/#sec-Input-Objects

func (*InputObject) Description

func (t *InputObject) Description() string

func (*InputObject) Kind

func (*InputObject) Kind() string

func (*InputObject) String

func (t *InputObject) String() string

func (*InputObject) TypeName

func (t *InputObject) TypeName() string

type InputValueDefinition

type InputValueDefinition struct {
	Name       Ident
	Type       Type
	Default    Value
	Desc       string
	Directives DirectiveList
	Loc        errors.Location
	TypeLoc    errors.Location
}

InputValueDefinition is a representation of the GraphQL InputValueDefinition.

http://spec.graphql.org/draft/#InputValueDefinition

type InputValueDefinitionList

type InputValueDefinitionList []*InputValueDefinition

func (InputValueDefinitionList) Get

Returns an InputValueDefinition by name or nil if not found.

type InterfaceTypeDefinition

type InterfaceTypeDefinition struct {
	Name          string
	PossibleTypes []*ObjectTypeDefinition
	Fields        FieldsDefinition
	Desc          string
	Directives    DirectiveList
	Loc           errors.Location
	Interfaces    []*InterfaceTypeDefinition
}

InterfaceTypeDefinition recusrively defines list of named fields with their arguments via the implementation chain of interfaces.

GraphQL objects can then implement these interfaces which requires that the object type will define all fields defined by those interfaces.

http://spec.graphql.org/draft/#sec-Interfaces

func (*InterfaceTypeDefinition) Description

func (t *InterfaceTypeDefinition) Description() string

func (*InterfaceTypeDefinition) Kind

func (*InterfaceTypeDefinition) String

func (t *InterfaceTypeDefinition) String() string

func (*InterfaceTypeDefinition) TypeName

func (t *InterfaceTypeDefinition) TypeName() string

type List

type List struct {
	// OfType represents the inner-type of a List type.
	// For example, the List type `[Foo]` has an OfType of Foo.
	OfType Type
}

List represents a GraphQL ListType.

http://spec.graphql.org/draft/#ListType

func (*List) Kind

func (*List) Kind() string

func (*List) String

func (t *List) String() string

type ListValue

type ListValue struct {
	Values []Value
	Loc    errors.Location
}

ListValue represents a literal list Value in the GraphQL specification.

http://spec.graphql.org/draft/#sec-List-Value

func (*ListValue) Deserialize

func (val *ListValue) Deserialize(vars map[string]interface{}) interface{}

func (*ListValue) Location

func (val *ListValue) Location() errors.Location

func (*ListValue) String

func (val *ListValue) String() string

type NamedType

type NamedType interface {
	Type
	TypeName() string
	Description() string
}

NamedType represents a type with a name.

http://spec.graphql.org/draft/#NamedType

type NonNull

type NonNull struct {
	// OfType represents the inner-type of a NonNull type.
	// For example, the NonNull type `Foo!` has an OfType of Foo.
	OfType Type
}

NonNull represents a GraphQL NonNullType.

https://spec.graphql.org/draft/#NonNullType

func (*NonNull) Kind

func (*NonNull) Kind() string

func (*NonNull) String

func (t *NonNull) String() string

type NullValue

type NullValue struct {
	Loc errors.Location
}

NullValue represents a literal `null` Value in the GraphQL specification.

http://spec.graphql.org/draft/#sec-Null-Value

func (*NullValue) Deserialize

func (val *NullValue) Deserialize(vars map[string]interface{}) interface{}

func (*NullValue) Location

func (val *NullValue) Location() errors.Location

func (*NullValue) String

func (val *NullValue) String() string

type ObjectField

type ObjectField struct {
	Name  Ident
	Value Value
}

ObjectField represents field/value pairs in a literal ObjectValue.

type ObjectTypeDefinition

type ObjectTypeDefinition struct {
	Name           string
	Interfaces     []*InterfaceTypeDefinition
	Fields         FieldsDefinition
	Desc           string
	Directives     DirectiveList
	InterfaceNames []string
	Loc            errors.Location
}

ObjectTypeDefinition represents a GraphQL ObjectTypeDefinition.

type FooObject {
		foo: String
}

https://spec.graphql.org/draft/#sec-Objects

func (*ObjectTypeDefinition) Description

func (t *ObjectTypeDefinition) Description() string

func (*ObjectTypeDefinition) Kind

func (*ObjectTypeDefinition) Kind() string

func (*ObjectTypeDefinition) String

func (t *ObjectTypeDefinition) String() string

func (*ObjectTypeDefinition) TypeName

func (t *ObjectTypeDefinition) TypeName() string

type ObjectValue

type ObjectValue struct {
	Fields []*ObjectField
	Loc    errors.Location
}

ObjectValue represents a literal object Value in the GraphQL specification.

http://spec.graphql.org/draft/#sec-Object-Value

func (*ObjectValue) Deserialize

func (val *ObjectValue) Deserialize(vars map[string]interface{}) interface{}

func (*ObjectValue) Location

func (val *ObjectValue) Location() errors.Location

func (*ObjectValue) String

func (val *ObjectValue) String() string

type OperationDefinition

type OperationDefinition struct {
	Type       OperationType
	Name       Ident
	Vars       ArgumentsDefinition
	Selections SelectionSet
	Directives DirectiveList
	Loc        errors.Location
}

OperationDefinition represents a GraphQL Operation.

https://spec.graphql.org/draft/#sec-Language.Operations

type OperationList

type OperationList []*OperationDefinition

func (OperationList) Get

Get returns an OperationDefinition by name or nil if not found.

type OperationType

type OperationType string

type PrimitiveValue

type PrimitiveValue struct {
	Type rune
	Text string
	Loc  errors.Location
}

PrimitiveValue represents one of the following GraphQL scalars: Int, Float, String, or Boolean

func (*PrimitiveValue) Deserialize

func (val *PrimitiveValue) Deserialize(vars map[string]interface{}) interface{}

func (*PrimitiveValue) Location

func (val *PrimitiveValue) Location() errors.Location

func (*PrimitiveValue) String

func (val *PrimitiveValue) String() string

type ScalarTypeDefinition

type ScalarTypeDefinition struct {
	Name       string
	Desc       string
	Directives DirectiveList
	Loc        errors.Location
}

ScalarTypeDefinition types represent primitive leaf values (e.g. a string or an integer) in a GraphQL type system.

GraphQL responses take the form of a hierarchical tree; the leaves on these trees are GraphQL scalars.

http://spec.graphql.org/draft/#sec-Scalars

func (*ScalarTypeDefinition) Description

func (t *ScalarTypeDefinition) Description() string

func (*ScalarTypeDefinition) Kind

func (*ScalarTypeDefinition) Kind() string

func (*ScalarTypeDefinition) String

func (t *ScalarTypeDefinition) String() string

func (*ScalarTypeDefinition) TypeName

func (t *ScalarTypeDefinition) TypeName() string

type Schema

type Schema struct {
	// EntryPoints determines the place in the type system where `query`, `mutation`, and
	// `subscription` operations begin.
	//
	// http://spec.graphql.org/draft/#sec-Root-Operation-Types
	//
	EntryPoints map[string]NamedType

	// Types are the fundamental unit of any GraphQL schema.
	// There are six kinds of named types, and two wrapping types.
	//
	// http://spec.graphql.org/draft/#sec-Types
	Types map[string]NamedType

	// Directives are used to annotate various parts of a GraphQL document as an indicator that they
	// should be evaluated differently by a validator, executor, or client tool such as a code
	// generator.
	//
	// http://spec.graphql.org/#sec-Type-System.Directives
	Directives map[string]*DirectiveDefinition

	UseFieldResolvers bool

	EntryPointNames map[string]string
	Objects         []*ObjectTypeDefinition
	Unions          []*Union
	Enums           []*EnumTypeDefinition
	Extensions      []*Extension
	SchemaString    string
}

Schema represents a GraphQL service's collective type system capabilities. A schema is defined in terms of the types and directives it supports as well as the root operation types for each kind of operation: `query`, `mutation`, and `subscription`.

For a more formal definition, read the relevant section in the specification:

http://spec.graphql.org/draft/#sec-Schema

func (*Schema) Resolve

func (s *Schema) Resolve(name string) Type

type Selection

type Selection interface {
	// contains filtered or unexported methods
}

A Selection is a field requested in a GraphQL operation.

http://spec.graphql.org/draft/#Selection

type SelectionSet

type SelectionSet []Selection

A SelectionSet represents a collection of Selections

http://spec.graphql.org/draft/#sec-Selection-Sets

type Type

type Type interface {
	// Kind returns one possible GraphQL type kind. A type kind must be
	// valid as defined by the GraphQL spec.
	//
	// https://spec.graphql.org/draft/#sec-Type-Kinds
	Kind() string

	// String serializes a Type into a GraphQL specification format type.
	//
	// http://spec.graphql.org/draft/#sec-Serialization-Format
	String() string
}

type TypeName

type TypeName struct {
	Ident
}

TypeName is a base building block for GraphQL type references.

func (*TypeName) Kind

func (*TypeName) Kind() string

func (*TypeName) String

func (*TypeName) String() string

type Union

type Union struct {
	Name             string
	UnionMemberTypes []*ObjectTypeDefinition
	Desc             string
	Directives       DirectiveList
	TypeNames        []string
	Loc              errors.Location
}

Union types represent objects that could be one of a list of GraphQL object types, but provides no guaranteed fields between those types.

They also differ from interfaces in that object types declare what interfaces they implement, but are not aware of what unions contain them.

http://spec.graphql.org/draft/#sec-Unions

func (*Union) Description

func (t *Union) Description() string

func (*Union) Kind

func (*Union) Kind() string

func (*Union) String

func (t *Union) String() string

func (*Union) TypeName

func (t *Union) TypeName() string

type Value

type Value interface {
	// Deserialize transforms a GraphQL specification format literal into a Go type.
	Deserialize(vars map[string]interface{}) interface{}

	// String serializes a Value into a GraphQL specification format literal.
	String() string
	Location() errors.Location
}

Value represents a literal input or literal default value in the GraphQL Specification.

http://spec.graphql.org/draft/#sec-Input-Values

type Variable

type Variable struct {
	Name string
	Loc  errors.Location
}

Variable is used in GraphQL operations to parameterize an input value.

http://spec.graphql.org/draft/#Variable

func (Variable) Deserialize

func (v Variable) Deserialize(vars map[string]interface{}) interface{}

func (*Variable) Location

func (v *Variable) Location() errors.Location

func (Variable) String

func (v Variable) String() string

Jump to

Keyboard shortcuts

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