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 ¶
- type Argument
- type ArgumentList
- type ArgumentsDefinition
- type Directive
- type DirectiveDefinition
- type DirectiveList
- type EnumTypeDefinition
- type EnumValueDefinition
- type ExecutableDefinition
- type Extension
- type Field
- type FieldDefinition
- type FieldsDefinition
- type Fragment
- type FragmentDefinition
- type FragmentList
- type FragmentSpread
- type Ident
- type InlineFragment
- type InputObject
- type InputValueDefinition
- type InputValueDefinitionList
- type InterfaceTypeDefinition
- type List
- type ListValue
- type NamedType
- type NonNull
- type NullValue
- type ObjectField
- type ObjectTypeDefinition
- type ObjectValue
- type OperationDefinition
- type OperationList
- type OperationType
- type PrimitiveValue
- type ScalarTypeDefinition
- type Schema
- type Selection
- type SelectionSet
- type Type
- type TypeName
- type Union
- type Value
- type Variable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 ¶
func (a ArgumentsDefinition) Get(name string) *InputValueDefinition
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.
type DirectiveDefinition ¶
type DirectiveDefinition struct { Name string Desc string Locations []string Arguments ArgumentsDefinition Loc errors.Location }
DirectiveDefinition is a representation of the GraphQL DirectiveDefinition.
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.
type ExecutableDefinition ¶
type ExecutableDefinition struct { Operations OperationList Fragments FragmentList }
ExecutableDefinition represents a set of operations or fragments that can be executed against a schema.
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.
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.
type FieldsDefinition ¶
type FieldsDefinition []*FieldDefinition
FieldsDefinition is a list of an ObjectTypeDefinition's Fields.
https://spec.graphql.org/draft/#FieldsDefinition
func (FieldsDefinition) Get ¶
func (l FieldsDefinition) Get(name string) *FieldDefinition
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.
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.
type InlineFragment ¶
type InlineFragment struct { Fragment Directives DirectiveList Loc errors.Location }
InlineFragment is a representation of the GraphQL 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.
type InputValueDefinitionList ¶
type InputValueDefinitionList []*InputValueDefinition
func (InputValueDefinitionList) Get ¶
func (l InputValueDefinitionList) Get(name string) *InputValueDefinition
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 }
InterfaceTypeDefinition represents a list of named fields and their arguments.
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) Kind() string
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.
type ListValue ¶
ListValue represents a literal list Value in the GraphQL specification.
http://spec.graphql.org/draft/#sec-List-Value
func (*ListValue) Deserialize ¶
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.
type NullValue ¶
NullValue represents a literal `null` Value in the GraphQL specification.
http://spec.graphql.org/draft/#sec-Null-Value
func (*NullValue) Deserialize ¶
type ObjectField ¶
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.
type OperationList ¶
type OperationList []*OperationDefinition
func (OperationList) Get ¶
func (l OperationList) Get(name string) *OperationDefinition
Get returns an OperationDefinition by name or nil if not found.
type OperationType ¶
type OperationType string
type PrimitiveValue ¶
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 }
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:
type Selection ¶
type Selection interface {
// contains filtered or unexported methods
}
A Selection is a field requested in a GraphQL operation.
type SelectionSet ¶
type SelectionSet []Selection
A SelectionSet represents a collection of Selections
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.
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 ¶
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.
type Variable ¶
Variable is used in GraphQL operations to parameterize an input value.
http://spec.graphql.org/draft/#Variable