graphQL

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2023 License: GPL-3.0 Imports: 18 Imported by: 10

Documentation

Overview

The module util/graphQL is an implementation of the GraphQL query interface

Index

Constants

View Source
const (

	// Ranks of root operation types in 'typeSystem.root', 'OperationTypeDefinition.OpType' and 'OperationDefinition.OpType'
	QueryOp        = l_QUERY
	MutationOp     = l_MUTATION
	SubscriptionOp = l_SUBSCRIPTION
)
View Source
const (

	// Prefix added to error messages
	ErrorPrefix = "#util/graphQL:"
)

Variables

This section is empty.

Functions

func Compile

func Compile(r io.Reader) (*Document, Response)

func DecodeString

func DecodeString(s string) string

func ExecutableDefinitions

func ExecutableDefinitions(doc *Document) bool

func GetObjectValueInputField

func GetObjectValueInputField(ov *InputObjectValue, name string, value *Value) bool

func GetTypeFlatString added in v1.0.2

func GetTypeFlatString(t Type) string

func GetTypeString added in v1.0.2

func GetTypeString(t Type) string

func GetValue

func GetValue(argumentValues *A.Tree, name string, v *Value) bool

func GetValueFlatString

func GetValueFlatString(v Value) string

func GetValueString

func GetValueString(v Value) string

func InsertJsonValue

func InsertJsonValue(t *A.Tree, name string, value J.Value) bool

func PrintDocument

func PrintDocument(w io.Writer, doc *Document)

func ReadGraphQL

func ReadGraphQL(name string) (*Document, Response)

func ReadString

func ReadString(s string) (*Document, Response)

func ResponseToJson

func ResponseToJson(r Response) J.Json

func SetDir

func SetDir(td TypeDirectory)

func SetRComp

func SetRComp(rComp io.Reader)

func Unsubscribe

func Unsubscribe(responseStream *ResponseStream)

func Unwrap added in v1.0.2

func Unwrap(rootValue *OutputObjectValue, n int) interface{}

func WriteType added in v1.0.2

func WriteType(w io.Writer, t Type)

func WriteTypeFlat added in v1.0.2

func WriteTypeFlat(w io.Writer, t Type)

func WriteValue

func WriteValue(w io.Writer, v Value)

func WriteValueFlat

func WriteValueFlat(w io.Writer, v Value)

Types

type AbstractTypeResolver

type AbstractTypeResolver func(ts TypeSystem, td TypeDefinition, ov *OutputObjectValue) *ObjectTypeDefinition

type AnyPtr

type AnyPtr interface {
}

type AnyValue

type AnyValue struct {
	Any interface{}
}

func MakeAnyValue

func MakeAnyValue(any AnyPtr) *AnyValue

type Argument

type Argument struct {
	Name  *StrPtr
	Value Value
}

type Arguments

type Arguments []Argument

type ArgumentsDefinition

type ArgumentsDefinition []*InputValueDefinition

type BooleanValue

type BooleanValue struct {
	Boolean bool
}

func MakeBooleanValue

func MakeBooleanValue(b bool) *BooleanValue

type Definition

type Definition interface {
}

type Definitions

type Definitions []Definition

type Directive

type Directive struct {
	Name *StrPtr
	Args Arguments
}

type DirectiveDefinition

type DirectiveDefinition struct {
	Desc    *StringValue
	Name    *StrPtr
	ArgsDef ArgumentsDefinition
	Rep     bool
	DirLocs DirectiveLocations // != nil
	// contains filtered or unexported fields
}

type DirectiveLocation

type DirectiveLocation interface {
	LocM() int
}

type DirectiveLocations

type DirectiveLocations []DirectiveLocation

type Directives

type Directives []Directive

type Document

type Document struct {
	Defs Definitions
	// contains filtered or unexported fields
}

func (*Document) GetFlatString

func (doc *Document) GetFlatString() string

func (*Document) GetString

func (doc *Document) GetString() string

func (*Document) Write

func (doc *Document) Write(w io.Writer)

func (*Document) WriteFlat

func (doc *Document) WriteFlat(w io.Writer)

type EnumTypeDefinition

type EnumTypeDefinition struct {
	TypeDefinitionCommon
	EnumValsDef EnumValuesDefinition // != nil
}

func (*EnumTypeDefinition) TypeDefinitionC

func (e *EnumTypeDefinition) TypeDefinitionC() *TypeDefinitionCommon

type EnumTypeExtension

type EnumTypeExtension struct {
	TypeExtensionC
	EnumValsDef EnumValuesDefinition
}

func (*EnumTypeExtension) TEM

type EnumValue

type EnumValue struct {
	Enum *StrPtr
}

func MakeEnumValue

func MakeEnumValue(s string) *EnumValue

type EnumValueDefinition

type EnumValueDefinition struct {
	Desc    *StringValue
	EnumVal *EnumValue
	Dirs    Directives
	// contains filtered or unexported fields
}

type EnumValuesDefinition

type EnumValuesDefinition []*EnumValueDefinition

type ErrorElem

type ErrorElem struct {
	Message string
	// Locations in the compiled text
	Locations PosList
	// Path in the data structure
	Path Path
}

func (*ErrorElem) Compare

func (err1 *ErrorElem) Compare(err2 A.Comparer) A.Comp

type EventStream

type EventStream struct {
	EventStreamer
	ResponseStreams ResponseStreams
}

func MakeEventStream

func MakeEventStream(es EventStreamer) *EventStream

type EventStreamer

type EventStreamer interface {
	StreamName() string
	RecordNotificationProc(notification SourceEventNotification)
	CloseEvent()
}

Stream of OutputObjectValue(s)

type ExecSystem

type ExecSystem interface {
	TypeSystem
	ListOperations() StrArray
	GetOperation(operationName string) *OperationDefinition

	Execute(doc *Document, operationName string, variableValues *A.Tree) Response // *ValMapItem
	// contains filtered or unexported methods
}

type ExecutableDefinition

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

type ExecutableDirectiveLocation

type ExecutableDirectiveLocation struct {
	Loc int
}

func (ExecutableDirectiveLocation) LocM

func (dir ExecutableDirectiveLocation) LocM() int

type Field

type Field struct {
	Alias,
	Name *StrPtr
	Arguments Arguments
	Dirs      Directives

	SelSet SelectionSet
	// contains filtered or unexported fields
}

func (*Field) DirsM

func (f *Field) DirsM() Directives

type FieldDefinition

type FieldDefinition struct {
	Desc    *StringValue
	Name    *StrPtr
	ArgsDef ArgumentsDefinition
	Type    Type
	Dirs    Directives
	// contains filtered or unexported fields
}

type FieldResolver

type FieldResolver func(ts TypeSystem, rootValue *OutputObjectValue, argumentValues *A.Tree) Value // *ValMapItem

type FieldsDefinition

type FieldsDefinition []*FieldDefinition

type FloatValue

type FloatValue struct {
	Float float64
}

func MakeFloat32Value

func MakeFloat32Value(f float32) *FloatValue

func MakeFloat64Value

func MakeFloat64Value(f float64) *FloatValue

type FragmentDefinition

type FragmentDefinition struct {
	Name     *StrPtr
	TypeCond *NamedType // != nil
	Dirs     Directives
	SelSet   SelectionSet
}

type FragmentSpread

type FragmentSpread struct {
	Name *StrPtr
	Dirs Directives
}

func (*FragmentSpread) DirsM

func (f *FragmentSpread) DirsM() Directives

type InlineFragment

type InlineFragment struct {
	TypeCond *NamedType // may be nil
	Dirs     Directives
	SelSet   SelectionSet
}

func (*InlineFragment) DirsM

func (i *InlineFragment) DirsM() Directives

type InputObjectTypeDefinition

type InputObjectTypeDefinition struct {
	TypeDefinitionCommon
	InFieldsDef ArgumentsDefinition //  != nil
}

func (*InputObjectTypeDefinition) TypeDefinitionC

func (i *InputObjectTypeDefinition) TypeDefinitionC() *TypeDefinitionCommon

type InputObjectTypeExtension

type InputObjectTypeExtension struct {
	TypeExtensionC
	InFieldsDef ArgumentsDefinition
}

func (*InputObjectTypeExtension) TEM

type InputObjectValue

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

func (*InputObjectValue) First

func (ov *InputObjectValue) First() *ObjectField

func (*InputObjectValue) Next

type InputValueDefinition

type InputValueDefinition struct {
	Desc   *StringValue
	Name   *StrPtr
	Type   Type
	DefVal Value
	Dirs   Directives
}

type InstantResponse

type InstantResponse struct {
	Data *OutputObjectValue
	// contains filtered or unexported fields
}

func (*InstantResponse) Errors

func (r *InstantResponse) Errors() *A.Tree

func (*InstantResponse) SetErrors

func (r *InstantResponse) SetErrors(err *A.Tree)

type IntValue

type IntValue struct {
	Int int64
}

func MakeInt64Value

func MakeInt64Value(n int64) *IntValue

func MakeIntValue

func MakeIntValue(n int) *IntValue

type InterfaceTypeDefinition

type InterfaceTypeDefinition struct {
	TypeDefinitionCommon
	ImpInter  NamedTypes
	FieldsDef FieldsDefinition
	// contains filtered or unexported fields
}

func (*InterfaceTypeDefinition) TypeDefinitionC

func (i *InterfaceTypeDefinition) TypeDefinitionC() *TypeDefinitionCommon

type InterfaceTypeExtension

type InterfaceTypeExtension struct {
	TypeExtensionC
	ImpInter  NamedTypes
	FieldsDef FieldsDefinition
}

func (*InterfaceTypeExtension) TEM

type LinkGQL

type LinkGQL func(name string) io.ReadCloser

LinkGQL(name) returns the ReadCloser corresponding to name

func SetLGQL

func SetLGQL(lG LinkGQL) LinkGQL

SetLGQL sets the current LinkGQL function and returns the previous one

type ListType

type ListType struct {
	ItemT Type
}

type ListValue

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

func NewListValue

func NewListValue() *ListValue

func (*ListValue) Append

func (lv *ListValue) Append(value Value)

func (*ListValue) First

func (lv *ListValue) First() *ValueElem

func (*ListValue) Len

func (lv *ListValue) Len() int

func (*ListValue) Next

func (lv *ListValue) Next(l *ValueElem) *ValueElem

type NameMapItem

type NameMapItem struct {
	Name *StrPtr
}

Base type of elements of an avl tree

func (*NameMapItem) Compare

func (n1 *NameMapItem) Compare(n2 A.Comparer) A.Comp

func (*NameMapItem) Copy

func (n *NameMapItem) Copy() A.Copier

type NamedType

type NamedType struct {
	Name *StrPtr
}

type NamedTypes

type NamedTypes []*NamedType

type NonNullType

type NonNullType struct {
	NullT Type
}

type NullValue

type NullValue struct {
}

func MakeNullValue

func MakeNullValue() *NullValue

type ObjectField

type ObjectField struct {
	Name  *StrPtr
	Value Value
	// contains filtered or unexported fields
}

type ObjectTypeDefinition

type ObjectTypeDefinition struct {
	TypeDefinitionCommon
	ImpInter  NamedTypes
	FieldsDef FieldsDefinition // != nil
}

func (*ObjectTypeDefinition) TypeDefinitionC

func (o *ObjectTypeDefinition) TypeDefinitionC() *TypeDefinitionCommon

type ObjectTypeExtension

type ObjectTypeExtension struct {
	TypeExtensionC
	ImpInter  NamedTypes
	FieldsDef FieldsDefinition
}

func (*ObjectTypeExtension) TEM

type OperationDefinition

type OperationDefinition struct {
	OpType  int
	Name    *StrPtr
	VarDefs VariableDefinitions
	Dirs    Directives
	SelSet  SelectionSet
}

type OperationTypeDefinition

type OperationTypeDefinition struct {
	OpType int
	Type   *NamedType
}

type OperationTypeDefinitions

type OperationTypeDefinitions []OperationTypeDefinition

type OutputObjectValue

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

func NewOutputObjectValue

func NewOutputObjectValue() *OutputObjectValue

func Wrap added in v1.0.2

func Wrap(i ...interface{}) *OutputObjectValue

func (*OutputObjectValue) First

func (ov *OutputObjectValue) First() *ObjectField

func (*OutputObjectValue) InsertOutputField

func (ov *OutputObjectValue) InsertOutputField(name string, value Value) *ObjectField

Exported variant of 'insertOutputField' using string instead of *StrPtr

func (*OutputObjectValue) Next

type Path

type Path interface {
	Next() Path
	// contains filtered or unexported methods
}

Path of an error in data structure

type PathBuilder

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

Queue

func NewPathBuilder

func NewPathBuilder() *PathBuilder

func (*PathBuilder) GetPath

func (pb *PathBuilder) GetPath() Path

func (*PathBuilder) PushPathNb

func (pb *PathBuilder) PushPathNb(n int) *PathBuilder

func (*PathBuilder) PushPathString

func (pb *PathBuilder) PushPathString(s string) *PathBuilder

type PathNb

type PathNb struct {
	N int
	// contains filtered or unexported fields
}

func (*PathNb) Next

func (p *PathNb) Next() Path

type PathString

type PathString struct {
	S string
	// contains filtered or unexported fields
}

func (*PathString) Next

func (p *PathString) Next() Path

type PosList added in v1.0.4

type PosList []*PosT

type PosT

type PosT struct {
	// Position from start in bytes, line number, column number in bytes
	P, L, C int
}

Position in compiled text

type Response

type Response interface {
	Errors() *A.Tree       // *ErrorElem
	SetErrors(err *A.Tree) // *ErrorElem
}

type ResponseStream

type ResponseStream struct {
	ResponseStreamer
	SourceStream *EventStream
	// contains filtered or unexported fields
}

Stream of Response(s)

func (*ResponseStream) FixResponseStream

func (rs *ResponseStream) FixResponseStream(s ResponseStreamer)

type ResponseStreamer

type ResponseStreamer interface {
	ManageResponseEvent(r Response)
}

type ResponseStreams

type ResponseStreams []*ResponseStream

type ScalarCoercer

type ScalarCoercer func(ts TypeSystem, v Value, path Path, cV *Value) bool

A 'ScalarCoercer' tries to coerce 'v' to a scalar value *'cV' valid for this coercer. If success, 'ScalarCoercer' returns true; otherwise, an error is raised in 'ts' with the path 'path' and 'ScalarCoercer' returns false

type ScalarTypeDefinition

type ScalarTypeDefinition struct {
	TypeDefinitionCommon
	SpecifiedByURL *StringValue
	// contains filtered or unexported fields
}

func (*ScalarTypeDefinition) TypeDefinitionC

func (s *ScalarTypeDefinition) TypeDefinitionC() *TypeDefinitionCommon

type ScalarTypeExtension

type ScalarTypeExtension struct {
	TypeExtensionC
}

func (*ScalarTypeExtension) TEM

type Scalarer

type Scalarer interface {
	FixScalarCoercer(scalarName string, sc *ScalarCoercer)
}

type SchemaDefinition

type SchemaDefinition struct {
	Desc       *StringValue
	Dirs       Directives
	OpTypeDefs OperationTypeDefinitions
	// contains filtered or unexported fields
}

type SchemaExtension

type SchemaExtension struct {
	Dirs       Directives
	OpTypeDefs OperationTypeDefinitions
}

type Selection

type Selection interface {
	DirsM() Directives
}

type SelectionSet

type SelectionSet []Selection

type SourceEventNotification

type SourceEventNotification func(es *EventStream, event *OutputObjectValue)

type StrArray

type StrArray []string

type StrPtr

type StrPtr struct {
	P *PosT
	S string
}

Aggregate of a string and of its position in compiled text

type StreamResolver

type StreamResolver func(rootValue *OutputObjectValue, argumentValues *A.Tree) *EventStream // *ValMapItem

type StringValue

type StringValue struct {
	String *StrPtr
}

func MakeStringValue

func MakeStringValue(s string) *StringValue

type SubscribeResponse

type SubscribeResponse struct {
	Data *ResponseStream
	Name string
	// contains filtered or unexported fields
}

func (*SubscribeResponse) Errors

func (r *SubscribeResponse) Errors() *A.Tree

func (*SubscribeResponse) SetErrors

func (r *SubscribeResponse) SetErrors(err *A.Tree)

type Type

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

type TypeDefinition

type TypeDefinition interface {
	TypeSystemDefinition
	TypeDefinitionC() *TypeDefinitionCommon
}

type TypeDefinitionCommon

type TypeDefinitionCommon struct {
	Desc *StringValue
	Name *StrPtr
	Dirs Directives
	// contains filtered or unexported fields
}

type TypeDirectory

type TypeDirectory interface {
	NewTypeSystem(sc Scalarer) TypeSystem
}
var (
	StdDir TypeDirectory = new(typeDirectory)
	Dir                  = StdDir
)

type TypeExtension

type TypeExtension interface {
	TypeSystemExtension
	TEM() *TypeExtensionC
}

type TypeExtensionC

type TypeExtensionC struct {
	Name *StrPtr
	Dirs Directives
}

type TypeSystem

type TypeSystem interface {
	Scalarer
	Error(mes string, pos PosList, path Path)
	MappedError(mes, aux1, aux2 string, pos PosList, path Path)

	GetErrors() *A.Tree // *ErrorElem
	GetTypeDefinition(name string) TypeDefinition
	FixFieldResolver(object, field string, resolver FieldResolver)
	FixStreamResolver(fieldName string, resolver StreamResolver)
	FixAbstractTypeResolver(resolver AbstractTypeResolver)
	InitTypeSystem(doc *Document)
	ExecValidate(doc *Document) ExecSystem
	FixInitialValue(ov *OutputObjectValue)
	// contains filtered or unexported methods
}

type TypeSystemDefinition

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

type TypeSystemDirectiveLocation

type TypeSystemDirectiveLocation struct {
	Loc int
}

func (TypeSystemDirectiveLocation) LocM

func (dir TypeSystemDirectiveLocation) LocM() int

type TypeSystemExtension

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

type UnionTypeDefinition

type UnionTypeDefinition struct {
	TypeDefinitionCommon
	UnionMTypes NamedTypes
}

func (*UnionTypeDefinition) TypeDefinitionC

func (u *UnionTypeDefinition) TypeDefinitionC() *TypeDefinitionCommon

type UnionTypeExtension

type UnionTypeExtension struct {
	TypeExtensionC
	UnionMTypes NamedTypes
}

func (*UnionTypeExtension) TEM

type ValMapItem

type ValMapItem struct {
	NameMapItem
	Value Value
}

type Value

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

func TransVal

func TransVal(value J.Value) Value

JSON -> graphQL

type ValueElem

type ValueElem struct {
	Value Value
	// contains filtered or unexported fields
}

type Variable

type Variable struct {
	Name *StrPtr
}

type VariableDefinition

type VariableDefinition struct {
	Var    *StrPtr
	Type   Type
	DefVal Value
	Dirs   Directives
}

type VariableDefinitions

type VariableDefinitions []*VariableDefinition

Directories

Path Synopsis
examples
static
The package graphQL is an implementation of the GraphQL query interface This package must be imported for its side effects when the GraphQL compiler and errors are stored in "util/graphQL/static" (file "compVar.go", variable "compiler" and file errorsVar.go, var strEn)
The package graphQL is an implementation of the GraphQL query interface This package must be imported for its side effects when the GraphQL compiler and errors are stored in "util/graphQL/static" (file "compVar.go", variable "compiler" and file errorsVar.go, var strEn)
The package graphQL is an implementation of the GraphQL query interface This package must be imported for its side effects when the GraphQL compiler and errors are stored in "util/graphQL/static" (file "compVar.go", variable "compiler" and file errorsVar.go, var strEn)
The package graphQL is an implementation of the GraphQL query interface This package must be imported for its side effects when the GraphQL compiler and errors are stored in "util/graphQL/static" (file "compVar.go", variable "compiler" and file errorsVar.go, var strEn)

Jump to

Keyboard shortcuts

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