Documentation ¶
Overview ¶
Package gqlparse provides a GraphQL parser that validates queries, ignores irrelevant operations inlines fragments and references variable values.
Index ¶
- Constants
- func WriteTypeDesignation(w io.Writer, definition []Token)
- func WriteValue(w io.Writer, definition []Token)
- type ErrorFragLimitExceeded
- type ErrorFragRecurse
- type ErrorFragUndefined
- type ErrorFragUnused
- type ErrorOprAnonNonExcl
- type ErrorOprNotFound
- type ErrorRedecFrag
- type ErrorRedecOpr
- type ErrorRedeclVar
- type ErrorSyntax
- type ErrorUnexpValType
- type ErrorVarJSONNotObj
- type ErrorVarJSONSyntax
- type ErrorVarUndeclared
- type ErrorVarUndefined
- type Parser
- type Token
Constants ¶
const TokenTypeValIndexOffset = 100
TokenTypeValIndexOffset defines the offset that needs to be subtracted from Token.ID in order to get the index of the value when Token.ID is > 99
Variables ¶
This section is empty.
Functions ¶
func WriteTypeDesignation ¶
WriteTypeDesignation stringifies a type designation to w expecting definition to be valid.
func WriteValue ¶
WriteValue stringifies a value to w expecting definition to be valid.
Types ¶
type ErrorFragLimitExceeded ¶
type ErrorFragLimitExceeded struct {
Limit int
}
func (*ErrorFragLimitExceeded) Error ¶
func (e *ErrorFragLimitExceeded) Error() string
type ErrorFragRecurse ¶
type ErrorFragRecurse struct {
Path [][]byte
}
func (*ErrorFragRecurse) Error ¶
func (e *ErrorFragRecurse) Error() string
type ErrorFragUndefined ¶
type ErrorFragUndefined struct {
FragmentName []byte
}
func (*ErrorFragUndefined) Error ¶
func (e *ErrorFragUndefined) Error() string
type ErrorFragUnused ¶
type ErrorFragUnused struct {
FragmentName []byte
}
func (*ErrorFragUnused) Error ¶
func (e *ErrorFragUnused) Error() string
type ErrorOprAnonNonExcl ¶
type ErrorOprAnonNonExcl struct { }
func (*ErrorOprAnonNonExcl) Error ¶
func (e *ErrorOprAnonNonExcl) Error() string
type ErrorOprNotFound ¶
type ErrorOprNotFound struct {
OperationName []byte
}
func (*ErrorOprNotFound) Error ¶
func (e *ErrorOprNotFound) Error() string
type ErrorRedecFrag ¶
type ErrorRedecFrag struct {
FragmentName []byte
}
func (*ErrorRedecFrag) Error ¶
func (e *ErrorRedecFrag) Error() string
type ErrorRedecOpr ¶
type ErrorRedecOpr struct {
OperationName []byte
}
func (*ErrorRedecOpr) Error ¶
func (e *ErrorRedecOpr) Error() string
type ErrorRedeclVar ¶
type ErrorRedeclVar struct {
VariableName []byte
}
func (*ErrorRedeclVar) Error ¶
func (e *ErrorRedeclVar) Error() string
type ErrorSyntax ¶
func (*ErrorSyntax) Error ¶
func (e *ErrorSyntax) Error() string
type ErrorUnexpValType ¶
type ErrorUnexpValType struct { Buffer []Token BufferJSON []byte TypeExpected indexRange DefaultValueReceived indexRange JSONValueReceived indexRange }
func (*ErrorUnexpValType) Error ¶
func (e *ErrorUnexpValType) Error() string
type ErrorVarJSONNotObj ¶
func (*ErrorVarJSONNotObj) Error ¶
func (e *ErrorVarJSONNotObj) Error() string
type ErrorVarJSONSyntax ¶
type ErrorVarJSONSyntax struct{}
func (*ErrorVarJSONSyntax) Error ¶
func (e *ErrorVarJSONSyntax) Error() string
type ErrorVarUndeclared ¶
type ErrorVarUndeclared struct {
VariableName []byte
}
func (*ErrorVarUndeclared) Error ¶
func (e *ErrorVarUndeclared) Error() string
type ErrorVarUndefined ¶
type ErrorVarUndefined struct {
VariableName []byte
}
func (*ErrorVarUndefined) Error ¶
func (e *ErrorVarUndefined) Error() string
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func NewParser ¶
func NewParser() *Parser
NewParser creates a new parser instance. It's adviced to create only one parser per goroutine as calling (*Parser).Parse will reset it.
func (*Parser) Parse ¶
func (r *Parser) Parse( src, operationName, varsJSON []byte, onSuccess func( varValues [][]Token, operation []Token, selectionSet []Token, ), onError func(err error), )
Parse calls onSuccess in case of success where operation only contains the relevant set of tokens. onError is called in case of an error.
WARNING: Data (including errors) provided to callbacks must not be aliased and used after Parse returns!
type Token ¶
type Token struct { // IDs below 100 are reserved gqlscan type identifiers. // IDs above 99 are variable value indexes. ID gqlscan.Token Value []byte }
func MakeVariableIndexToken ¶
MakeVariableIndexToken creates a variable index token.
func (Token) VariableIndex ¶
VariableIndex returns the index of the varible value if its a variable index token, otherwise returns -1.