common

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2022 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package common adapted from https://github.com/graph-gophers/graphql-go/blob/master/internal/common.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseArgumentList

func ParseArgumentList(l *Lexer) types.ArgumentList

ParseArgumentList returns an ArgumentList for a lexer instance

func ParseDirectives

func ParseDirectives(l *Lexer) types.DirectiveList

ParseDirectives returns slice of DirectivesList

func ParseInputValue

func ParseInputValue(l *Lexer) *types.InputValueDefinition

ParseInputValue returns a parsed input value definition of a lexer instance

func ParseLiteral

func ParseLiteral(l *Lexer, constOnly bool) types.Value

ParseLiteral returns an interface value

func ParseType

func ParseType(l *Lexer) types.Type

ParseType returns an interface Type of a passed in lexer instance

func ResolveType

func ResolveType(t types.Type, resolver Resolver) (types.Type, *errors.QueryError)

ResolveType attempts to resolve a type's name against a resolving function. This function is used when one needs to check if a TypeName exists in the resolver (typically a Schema).

In the example below, ResolveType would be used to check if the resolving function returns a valid type for Dimension:

type Profile {
   picture(dimensions: Dimension): Url
}

ResolveType recursively unwraps List and NonNull types until a NamedType is reached.

Types

type Ident

type Ident struct {
	Name string
	Loc  errors.Location
}

Ident Fields

type Lexer

type Lexer struct {
	// contains filtered or unexported fields
}

Lexer fields

func NewLexer

func NewLexer(s string, useStringDescriptions bool) *Lexer

NewLexer creates a new instance of Lexer

func (*Lexer) CatchScannerError

func (l *Lexer) CatchScannerError(s *scanner.Scanner, msg string)

CatchScannerError handles errors during message scanning

func (*Lexer) CatchSyntaxError

func (l *Lexer) CatchSyntaxError(f func()) (errRes *errors.QueryError)

CatchSyntaxError provides error checking for Lexer instance

func (*Lexer) ConsumeIdent

func (l *Lexer) ConsumeIdent() string

ConsumeIdent consumes identifer

func (*Lexer) ConsumeIdentWithLoc

func (l *Lexer) ConsumeIdentWithLoc() types.Ident

ConsumeIdentWithLoc consumes indentifer and returns Ident with location

func (*Lexer) ConsumeKeyword

func (l *Lexer) ConsumeKeyword(keyword string)

ConsumeKeyword consumes keyword

func (*Lexer) ConsumeLiteral

func (l *Lexer) ConsumeLiteral() *types.PrimitiveValue

ConsumeLiteral consumes literal and returns primitive value

func (*Lexer) ConsumeToken

func (l *Lexer) ConsumeToken(expected rune)

ConsumeToken consumes tokens

func (*Lexer) ConsumeWhitespace

func (l *Lexer) ConsumeWhitespace()

ConsumeWhitespace consumes whitespace and tokens equivalent to whitespace (e.g. commas and comments).

Consumed comment characters will build the description for the next type or field encountered. The description is available from `DescComment()`, and will be reset every time `ConsumeWhitespace()` is executed unless l.useStringDescriptions is set.

func (*Lexer) DescComment

func (l *Lexer) DescComment() string

DescComment consumes comment

func (*Lexer) Location

func (l *Lexer) Location() errors.Location

Location returns location

func (*Lexer) Peek

func (l *Lexer) Peek() rune

Peek looks as next token

func (*Lexer) SyntaxError

func (l *Lexer) SyntaxError(message string)

SyntaxError panics if inputer message has error

type Resolver

type Resolver func(name string) types.Type

Resolver returns interface Type

Jump to

Keyboard shortcuts

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