Documentation
¶
Overview ¶
Package gqlang provides a parser for the GraphQL language.
Index ¶
- type Argument
- type Arguments
- type ArgumentsDefinition
- type DefaultValue
- type Definition
- type Description
- type Directive
- type Directives
- type Document
- type EnumTypeDefinition
- type EnumValueDefinition
- type EnumValuesDefinition
- type Field
- type FieldDefinition
- type FieldsDefinition
- type FragmentDefinition
- type FragmentSpread
- type InlineFragment
- type InputFieldsDefinition
- type InputObjectField
- type InputObjectTypeDefinition
- type InputObjectValue
- type InputValue
- type InputValueDefinition
- type ListType
- type ListValue
- type Name
- type NonNullType
- type ObjectTypeDefinition
- type Operation
- type OperationType
- type Pos
- type Position
- type ScalarType
- type ScalarTypeDefinition
- type ScalarValue
- type Selection
- type SelectionSet
- type TypeCondition
- type TypeDefinition
- type TypeRef
- type UnionTypeDefinition
- type Variable
- type VariableDefinition
- type VariableDefinitions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Argument ¶
type Argument struct { Name *Name Colon Pos Value *InputValue }
Argument is a single element in Arguments. https://graphql.github.io/graphql-spec/June2018/#sec-Language.Arguments
type Arguments ¶
Arguments is a set of named arguments on a field. https://graphql.github.io/graphql-spec/June2018/#sec-Language.Arguments
func (*Arguments) ByName ¶
ByName returns the first argument with the given name or nil if not found.
func (*Arguments) IdenticalTo ¶ added in v0.2.0
IdenticalTo reports whether args is structurally identical to args2, ignoring token positions and argument order. The result is undefined if either set of arguments contain multiple values for the same argument name.
type ArgumentsDefinition ¶
type ArgumentsDefinition struct { LParen Pos Args []*InputValueDefinition RParen Pos }
ArgumentsDefinition specifies the arguments for a FieldDefinition. https://graphql.github.io/graphql-spec/June2018/#ArgumentsDefinition
type DefaultValue ¶
type DefaultValue struct { Eq Pos Value *InputValue }
DefaultValue specifies the default value of an input. https://graphql.github.io/graphql-spec/June2018/#DefaultValue
type Definition ¶
type Definition struct { Operation *Operation Fragment *FragmentDefinition Type *TypeDefinition }
Definition is a top-level GraphQL construct like an operation, a fragment, or a type. Only one of its fields will be set. https://graphql.github.io/graphql-spec/June2018/#sec-Language.Document
func (*Definition) Start ¶
func (defn *Definition) Start() Pos
Start returns the position of the definition's first token.
type Description ¶
A Description is a string that documents a type system definition. https://graphql.github.io/graphql-spec/June2018/#Description
func (*Description) Value ¶
func (d *Description) Value() string
Value returns the string value of the description.
type Directives ¶ added in v0.2.0
type Directives []*Directive
Directives annotate parts of a GraphQL document.
type Document ¶
type Document struct {
Definitions []*Definition
}
Document is a parsed GraphQL source. https://graphql.github.io/graphql-spec/June2018/#sec-Language.Document
func (*Document) FindFragment ¶ added in v0.2.0
func (doc *Document) FindFragment(name string) *FragmentDefinition
FindFragment returns the fragment with the name or nil if not found.
func (*Document) FindOperation ¶ added in v0.2.0
FindOperation returns the operation with the name or nil if not found. If the name is the empty string, it returns the first operation.
type EnumTypeDefinition ¶
type EnumTypeDefinition struct { Description *Description Keyword Pos Name *Name Values *EnumValuesDefinition }
EnumTypeDefinition defines an enumeration type and its possible values. https://graphql.github.io/graphql-spec/June2018/#EnumTypeDefinition
type EnumValueDefinition ¶
type EnumValueDefinition struct { Description *Description Value *Name Directives Directives }
EnumValueDefinition is a possible value of an enumeration. https://graphql.github.io/graphql-spec/June2018/#EnumValueDefinition
type EnumValuesDefinition ¶
type EnumValuesDefinition struct { LBrace Pos Values []*EnumValueDefinition RBrace Pos }
EnumValuesDefinition is a brace-delimited list of enumeration values. https://graphql.github.io/graphql-spec/June2018/#EnumValuesDefinition
type Field ¶
type Field struct { Alias *Name Name *Name Arguments *Arguments SelectionSet *SelectionSet }
A Field is a discrete piece of information available to request within a selection set. https://graphql.github.io/graphql-spec/June2018/#sec-Language.Fields
type FieldDefinition ¶
type FieldDefinition struct { Description *Description Name *Name Args *ArgumentsDefinition Colon Pos Type *TypeRef Directives Directives }
FieldDefinition specifies a single field in an ObjectTypeDefinition. https://graphql.github.io/graphql-spec/June2018/#FieldsDefinition
type FieldsDefinition ¶
type FieldsDefinition struct { LBrace Pos Defs []*FieldDefinition RBrace Pos }
FieldsDefinition is the list of fields in an ObjectTypeDefinition. https://graphql.github.io/graphql-spec/June2018/#FieldsDefinition
type FragmentDefinition ¶ added in v0.2.0
type FragmentDefinition struct { Keyword Pos Name *Name Type *TypeCondition SelectionSet *SelectionSet }
A FragmentDefinition is a selection of fields. https://graphql.github.io/graphql-spec/June2018/#FragmentDefinition
type FragmentSpread ¶ added in v0.2.0
A FragmentSpread is a reference to a fragment inside a selection set. https://graphql.github.io/graphql-spec/June2018/#FragmentSpread
func (*FragmentSpread) String ¶ added in v0.2.0
func (spread *FragmentSpread) String() string
String returns the spread as "...name".
type InlineFragment ¶ added in v0.2.0
type InlineFragment struct { Ellipsis Pos Type *TypeCondition // may be nil SelectionSet *SelectionSet }
An InlineFragment is an anonymous fragment inside a selection set. https://graphql.github.io/graphql-spec/June2018/#InlineFragment
type InputFieldsDefinition ¶
type InputFieldsDefinition struct { LBrace Pos Defs []*InputValueDefinition RBrace Pos }
InputFieldsDefinition is the list of fields in an InputObjectTypeDefinition. https://graphql.github.io/graphql-spec/June2018/#InputFieldsDefinition
type InputObjectField ¶
type InputObjectField struct { Name *Name Colon Pos Value *InputValue }
An InputObjectField is a keyed input value.
type InputObjectTypeDefinition ¶
type InputObjectTypeDefinition struct { Description *Description Keyword Pos Name *Name Fields *InputFieldsDefinition }
InputObjectTypeDefinition names an input object type. https://graphql.github.io/graphql-spec/June2018/#InputObjectTypeDefinition
type InputObjectValue ¶
type InputObjectValue struct { LBrace Pos Fields []*InputObjectField RBrace Pos }
An InputObjectValue is an unordered list of keyed input values.
func (*InputObjectValue) IdenticalTo ¶ added in v0.2.0
func (ioval *InputObjectValue) IdenticalTo(ioval2 *InputObjectValue) bool
IdenticalTo reports whether ioval is structurally identical to ioval2, ignoring token positions and input object field order. The result is undefined if either value is or contains an input object which contain multiple values for the same field name.
func (*InputObjectValue) String ¶
func (ioval *InputObjectValue) String() string
String formats the value in GraphQL syntax.
type InputValue ¶
type InputValue struct { Null *Name Scalar *ScalarValue VariableRef *Variable List *ListValue InputObject *InputObjectValue }
An InputValue is a scalar or a variable reference. https://graphql.github.io/graphql-spec/June2018/#sec-Input-Values
func (*InputValue) IdenticalTo ¶ added in v0.2.0
func (ival *InputValue) IdenticalTo(ival2 *InputValue) bool
IdenticalTo reports whether ival is structurally identical to ival2, ignoring token positions and input object field order. The result is undefined if either value contains an input object which contain multiple values for the same field name.
func (*InputValue) Start ¶
func (ival *InputValue) Start() Pos
Start returns the byte offset of the beginning of the expression.
func (*InputValue) String ¶
func (ival *InputValue) String() string
String formats the expression as GraphQL syntax.
type InputValueDefinition ¶
type InputValueDefinition struct { Description *Description Name *Name Colon Pos Type *TypeRef Default *DefaultValue }
InputValueDefinition specifies an argument in a FieldDefinition or a field in an InputObjectTypeDefinition. https://graphql.github.io/graphql-spec/June2018/#InputValueDefinition
type ListType ¶
ListType declares a homogenous sequence of another type. https://graphql.github.io/graphql-spec/June2018/#ListType
type ListValue ¶
type ListValue struct { LBracket Pos Values []*InputValue RBracket Pos }
A ListValue is an ordered list literal.
func (*ListValue) IdenticalTo ¶ added in v0.2.0
IdenticalTo reports whether lval is structurally identical to lval2, ignoring token positions and input object field order. The result is undefined if either value contains an input object which contain multiple values for the same field name.
type Name ¶
A Name is an identifier. https://graphql.github.io/graphql-spec/June2018/#sec-Names
type NonNullType ¶
NonNullType declares a named or list type that cannot be null. https://graphql.github.io/graphql-spec/June2018/#Type
func (*NonNullType) Start ¶
func (nn *NonNullType) Start() Pos
Start returns the byte offset of the start of the type.
func (*NonNullType) String ¶
func (nn *NonNullType) String() string
String formats the type in GraphQL syntax.
type ObjectTypeDefinition ¶
type ObjectTypeDefinition struct { Description *Description Keyword Pos Name *Name Fields *FieldsDefinition }
ObjectTypeDefinition names an output object type. https://graphql.github.io/graphql-spec/June2018/#ObjectTypeDefinition
type Operation ¶
type Operation struct { Start Pos Type OperationType Name *Name VariableDefinitions *VariableDefinitions SelectionSet *SelectionSet }
Operation is a query, a mutation, or a subscription. https://graphql.github.io/graphql-spec/June2018/#sec-Language.Operations
type OperationType ¶
type OperationType int
OperationType is one of query, mutation, or subscription.
const ( Query OperationType = iota Mutation Subscription )
Types of operation.
func (OperationType) String ¶
func (typ OperationType) String() string
String returns the keyword that corresponds to the operation type.
type Pos ¶
type Pos int
A Pos is a 0-based byte offset in a GraphQL document.
func (Pos) ToPosition ¶
ToPosition converts a byte position into a line and column number.
type Position ¶
A Position is a line/column pair. Both are 1-based. The column is byte-based.
func ErrorPosition ¶
ErrorPosition attempts to extract an error's Position.
type ScalarType ¶
type ScalarType int
ScalarType indicates the type of a ScalarValue.
const ( StringScalar ScalarType = iota BooleanScalar EnumScalar IntScalar FloatScalar )
Scalar types.
type ScalarTypeDefinition ¶
type ScalarTypeDefinition struct { Description *Description Keyword Pos Name *Name }
ScalarTypeDefinition names a scalar type. https://graphql.github.io/graphql-spec/June2018/#ScalarTypeDefinition
type ScalarValue ¶
type ScalarValue struct { Start Pos Type ScalarType Raw string }
ScalarValue is a primitive literal like a string or integer.
func (*ScalarValue) IdenticalTo ¶ added in v0.2.0
func (sval *ScalarValue) IdenticalTo(sval2 *ScalarValue) bool
IdenticalTo reports whether sval has the same type and value as sval2.
func (*ScalarValue) Value ¶
func (sval *ScalarValue) Value() string
Value converts the raw scalar into a string.
type Selection ¶
type Selection struct { Field *Field FragmentSpread *FragmentSpread InlineFragment *InlineFragment }
A Selection is either a field or a fragment. https://graphql.github.io/graphql-spec/June2018/#sec-Selection-Sets
type SelectionSet ¶
SelectionSet is the set of information an operation requests. https://graphql.github.io/graphql-spec/June2018/#SelectionSet
type TypeCondition ¶ added in v0.2.0
TypeCondition specifies the type a fragment applies to. https://graphql.github.io/graphql-spec/June2018/#TypeCondition
func (*TypeCondition) String ¶ added in v0.2.0
func (cond *TypeCondition) String() string
String returns the condition in the form "on TypeName".
type TypeDefinition ¶
type TypeDefinition struct { Scalar *ScalarTypeDefinition Object *ObjectTypeDefinition Union *UnionTypeDefinition Enum *EnumTypeDefinition InputObject *InputObjectTypeDefinition }
TypeDefinition holds a type definition. https://graphql.github.io/graphql-spec/June2018/#TypeDefinition
func (*TypeDefinition) Description ¶
func (defn *TypeDefinition) Description() *Description
Description returns the type definition's description or nil if it does not have one.
func (*TypeDefinition) Name ¶
func (defn *TypeDefinition) Name() *Name
Name returns the type definition's name.
func (*TypeDefinition) Start ¶
func (defn *TypeDefinition) Start() Pos
Start returns the position of the type definition's first token.
type TypeRef ¶
type TypeRef struct { Named *Name List *ListType NonNull *NonNullType }
A TypeRef is a named type, a list type, or a non-null type. https://graphql.github.io/graphql-spec/June2018/#Type
type UnionTypeDefinition ¶ added in v0.7.0
type UnionTypeDefinition struct { Description *Description Keyword Pos Name *Name MemberTypes []*Name }
UnionTypeDefinition defines an type that permits any one of a list of types. https://graphql.github.io/graphql-spec/June2018/#UnionTypeDefinition
type Variable ¶
A Variable is an input to a GraphQL operation. https://graphql.github.io/graphql-spec/June2018/#Variable
type VariableDefinition ¶
type VariableDefinition struct { Var *Variable Colon Pos Type *TypeRef Default *DefaultValue }
VariableDefinition is an element of VariableDefinitions. https://graphql.github.io/graphql-spec/June2018/#Variable
type VariableDefinitions ¶
type VariableDefinitions struct { LParen Pos Defs []*VariableDefinition RParen Pos }
VariableDefinitions is the set of variables an operation defines. https://graphql.github.io/graphql-spec/June2018/#Variable