Documentation ¶
Index ¶
- Constants
- Variables
- type AfterFetchHook
- type Array
- type BatchFetch
- type BeforeFetchHook
- type Boolean
- type BufPair
- type CSVVariableRenderer
- type Context
- type ContextVariable
- type DataSource
- type DataSourceBatch
- type DataSourceBatchFactory
- type Defer
- type DeferField
- type EmptyArray
- type EmptyObject
- type Fetch
- type FetchKind
- type Fetcher
- type Fetches
- type Field
- type FieldExport
- type Float
- type FlushWriter
- type GraphQLResponse
- type GraphQLResponsePatch
- type GraphQLStreamingResponse
- type GraphQLSubscription
- type GraphQLSubscriptionTrigger
- type GraphQLVariableRenderer
- type HeaderVariable
- type HookContext
- type InputTemplate
- type Integer
- type JSONVariableRenderer
- type Node
- type NodeKind
- type Null
- type Object
- type ObjectVariable
- type ParallelFetch
- type PlainVariableRenderer
- type Position
- type ProcessResponseConfig
- type Request
- type Resolver
- func (r *Resolver) MergeBufPairData(from, to *BufPair, prefixDataWithComma bool)
- func (r *Resolver) MergeBufPairErrors(from, to *BufPair)
- func (r *Resolver) MergeBufPairs(from, to *BufPair, prefixDataWithComma bool)
- func (r *Resolver) ResolveGraphQLResponse(ctx *Context, response *GraphQLResponse, data []byte, writer io.Writer) (err error)
- func (r *Resolver) ResolveGraphQLResponsePatch(ctx *Context, patch *GraphQLResponsePatch, data, path, extraPath []byte, ...) (err error)
- func (r *Resolver) ResolveGraphQLStreamingResponse(ctx *Context, response *GraphQLStreamingResponse, data []byte, ...) (err error)
- func (r *Resolver) ResolveGraphQLSubscription(ctx *Context, subscription *GraphQLSubscription, writer FlushWriter) (err error)
- type SegmentType
- type SingleFetch
- type Stream
- type StreamField
- type String
- type SubscriptionDataSource
- type TemplateSegment
- type Variable
- type VariableKind
- type VariableRenderer
- type VariableSchema
- type Variables
Constants ¶
const ( NodeKindObject NodeKind = iota + 1 NodeKindEmptyObject NodeKindArray NodeKindEmptyArray NodeKindNull NodeKindString NodeKindBoolean NodeKindInteger NodeKindFloat FetchKindSingle FetchKind = iota + 1 FetchKindParallel FetchKindBatch )
Variables ¶
var (
ErrInvalidJsonSchema = errors.New("json schema validation failed on Variable Renderer")
)
var (
ErrUnableToResolve = errors.New("unable to resolve operation")
)
Functions ¶
This section is empty.
Types ¶
type AfterFetchHook ¶
type AfterFetchHook interface { OnData(ctx HookContext, output []byte, singleFlight bool) OnError(ctx HookContext, output []byte, singleFlight bool) }
type BatchFetch ¶ added in v1.28.0
type BatchFetch struct { Fetch *SingleFetch BatchFactory DataSourceBatchFactory }
func (*BatchFetch) FetchKind ¶ added in v1.28.0
func (_ *BatchFetch) FetchKind() FetchKind
type BeforeFetchHook ¶
type BeforeFetchHook interface {
OnBeforeFetch(ctx HookContext, input []byte)
}
type Boolean ¶
type Boolean struct { Path []string Nullable bool Export *FieldExport }
type BufPair ¶
type BufPair struct { Data *fastbuffer.FastBuffer Errors *fastbuffer.FastBuffer }
func NewBufPair ¶
func NewBufPair() *BufPair
type CSVVariableRenderer ¶ added in v1.37.0
type CSVVariableRenderer struct { Kind string // contains filtered or unexported fields }
CSVVariableRenderer is an implementation of VariableRenderer It renders the provided list of values as comma separated values in plaintext (no JSON encoding of values)
func NewCSVVariableRenderer ¶ added in v1.37.0
func NewCSVVariableRenderer(arrayValueType jsonparser.ValueType) *CSVVariableRenderer
func NewCSVVariableRendererFromTypeRef ¶ added in v1.37.0
func NewCSVVariableRendererFromTypeRef(operation, definition *ast.Document, variableTypeRef int) *CSVVariableRenderer
func (*CSVVariableRenderer) RenderVariable ¶ added in v1.37.0
type Context ¶
type Context struct { context.Context Variables []byte Request Request // contains filtered or unexported fields }
func NewContext ¶
func (*Context) SetAfterFetchHook ¶
func (c *Context) SetAfterFetchHook(hook AfterFetchHook)
func (*Context) SetBeforeFetchHook ¶
func (c *Context) SetBeforeFetchHook(hook BeforeFetchHook)
type ContextVariable ¶
type ContextVariable struct { Path []string Renderer VariableRenderer }
func (*ContextVariable) Equals ¶
func (c *ContextVariable) Equals(another Variable) bool
func (*ContextVariable) GetVariableKind ¶ added in v1.37.0
func (_ *ContextVariable) GetVariableKind() VariableKind
func (*ContextVariable) TemplateSegment ¶
func (c *ContextVariable) TemplateSegment() TemplateSegment
type DataSource ¶
type DataSourceBatch ¶ added in v1.28.0
type DataSourceBatch interface { Demultiplex(responseBufPair *BufPair, bufPairs []*BufPair) (err error) Input() *fastbuffer.FastBuffer }
type DataSourceBatchFactory ¶ added in v1.28.0
type DataSourceBatchFactory interface {
CreateBatch(inputs [][]byte) (DataSourceBatch, error)
}
type DeferField ¶
type DeferField struct{}
type EmptyArray ¶
type EmptyArray struct{}
func (*EmptyArray) NodeKind ¶
func (_ *EmptyArray) NodeKind() NodeKind
type EmptyObject ¶
type EmptyObject struct{}
func (*EmptyObject) NodeKind ¶
func (_ *EmptyObject) NodeKind() NodeKind
type Fetcher ¶ added in v1.28.0
type Fetcher struct { EnableSingleFlightLoader bool // contains filtered or unexported fields }
func NewFetcher ¶ added in v1.28.0
func (*Fetcher) Fetch ¶ added in v1.28.0
func (f *Fetcher) Fetch(ctx *Context, fetch *SingleFetch, preparedInput *fastbuffer.FastBuffer, buf *BufPair) (err error)
func (*Fetcher) FetchBatch ¶ added in v1.28.0
func (f *Fetcher) FetchBatch(ctx *Context, fetch *BatchFetch, preparedInputs []*fastbuffer.FastBuffer, bufs []*BufPair) (err error)
type Field ¶
type Field struct { Name []byte Value Node Position Position Defer *DeferField Stream *StreamField HasBuffer bool BufferID int OnTypeName []byte }
type FieldExport ¶ added in v1.39.0
FieldExport takes the value of the field during evaluation (rendering of the field) and stores it in the variables using the Path as JSON pointer.
type Float ¶
type Float struct { Path []string Nullable bool Export *FieldExport }
type FlushWriter ¶
type GraphQLResponse ¶
type GraphQLResponse struct {
Data Node
}
type GraphQLResponsePatch ¶
type GraphQLStreamingResponse ¶
type GraphQLStreamingResponse struct { InitialResponse *GraphQLResponse Patches []*GraphQLResponsePatch FlushInterval int64 }
type GraphQLSubscription ¶
type GraphQLSubscription struct { Trigger GraphQLSubscriptionTrigger Response *GraphQLResponse }
type GraphQLSubscriptionTrigger ¶
type GraphQLSubscriptionTrigger struct { Input []byte InputTemplate InputTemplate Variables Variables Source SubscriptionDataSource }
type GraphQLVariableRenderer ¶ added in v1.37.0
type GraphQLVariableRenderer struct { JSONSchema string Kind string // contains filtered or unexported fields }
GraphQLVariableRenderer is an implementation of VariableRenderer It renders variables according to the GraphQL Specification
func NewGraphQLVariableRenderer ¶ added in v1.37.0
func NewGraphQLVariableRenderer(jsonSchema string) *GraphQLVariableRenderer
NewGraphQLVariableRenderer - to be used in tests only
func NewGraphQLVariableRendererFromTypeRef ¶ added in v1.37.0
func NewGraphQLVariableRendererFromTypeRef(operation, definition *ast.Document, variableTypeRef int) (*GraphQLVariableRenderer, error)
NewGraphQLVariableRendererFromTypeRef creates a new GraphQLVariableRenderer The argument typeRef must exist on the operation ast.Document, otherwise it will panic!
func (*GraphQLVariableRenderer) RenderVariable ¶ added in v1.37.0
type HeaderVariable ¶
type HeaderVariable struct {
Path []string
}
func (*HeaderVariable) Equals ¶
func (h *HeaderVariable) Equals(another Variable) bool
func (*HeaderVariable) GetVariableKind ¶ added in v1.37.0
func (h *HeaderVariable) GetVariableKind() VariableKind
func (*HeaderVariable) TemplateSegment ¶
func (h *HeaderVariable) TemplateSegment() TemplateSegment
type HookContext ¶
type HookContext struct {
CurrentPath []byte
}
type InputTemplate ¶
type InputTemplate struct {
Segments []TemplateSegment
}
func (*InputTemplate) Render ¶
func (i *InputTemplate) Render(ctx *Context, data []byte, preparedInput *fastbuffer.FastBuffer) (err error)
type Integer ¶
type Integer struct { Path []string Nullable bool Export *FieldExport }
type JSONVariableRenderer ¶ added in v1.37.0
type JSONVariableRenderer struct { JSONSchema string Kind string // contains filtered or unexported fields }
JSONVariableRenderer is an implementation of VariableRenderer It renders the provided data as JSON If configured, it also does a JSON Validation Check before rendering
func NewJSONVariableRenderer ¶ added in v1.37.0
func NewJSONVariableRenderer() *JSONVariableRenderer
func NewJSONVariableRendererWithValidation ¶ added in v1.37.0
func NewJSONVariableRendererWithValidation(jsonSchema string) *JSONVariableRenderer
func NewJSONVariableRendererWithValidationFromTypeRef ¶ added in v1.37.0
func NewJSONVariableRendererWithValidationFromTypeRef(operation, definition *ast.Document, variableTypeRef int) (*JSONVariableRenderer, error)
NewJSONVariableRendererWithValidationFromTypeRef creates a new JSONVariableRenderer The argument typeRef must exist on the operation ast.Document, otherwise it will panic!
func (*JSONVariableRenderer) RenderVariable ¶ added in v1.37.0
type ObjectVariable ¶
type ObjectVariable struct { Path []string Renderer VariableRenderer }
func (*ObjectVariable) Equals ¶
func (o *ObjectVariable) Equals(another Variable) bool
func (*ObjectVariable) GetVariableKind ¶ added in v1.37.0
func (o *ObjectVariable) GetVariableKind() VariableKind
func (*ObjectVariable) TemplateSegment ¶
func (o *ObjectVariable) TemplateSegment() TemplateSegment
type ParallelFetch ¶
type ParallelFetch struct {
Fetches []Fetch
}
func (*ParallelFetch) FetchKind ¶
func (_ *ParallelFetch) FetchKind() FetchKind
type PlainVariableRenderer ¶ added in v1.37.0
type PlainVariableRenderer struct { JSONSchema string Kind string // contains filtered or unexported fields }
PlainVariableRenderer is an implementation of VariableRenderer It renders the provided data as plain text E.g. a provided JSON string of "foo" will be rendered as foo, without quotes. If a nested JSON Object is provided, it will be rendered as is. This renderer can be used e.g. to render the provided scalar into a URL.
func NewPlainVariableRenderer ¶ added in v1.37.0
func NewPlainVariableRenderer() *PlainVariableRenderer
func NewPlainVariableRendererWithValidation ¶ added in v1.37.0
func NewPlainVariableRendererWithValidation(jsonSchema string) *PlainVariableRenderer
func NewPlainVariableRendererWithValidationFromTypeRef ¶ added in v1.37.0
func NewPlainVariableRendererWithValidationFromTypeRef(operation, definition *ast.Document, variableTypeRef int) (*PlainVariableRenderer, error)
NewPlainVariableRendererWithValidationFromTypeRef creates a new PlainVariableRenderer The argument typeRef must exist on the operation ast.Document, otherwise it will panic!
func (*PlainVariableRenderer) RenderVariable ¶ added in v1.37.0
type ProcessResponseConfig ¶ added in v1.21.0
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
func New ¶
New returns a new Resolver, ctx.Done() is used to cancel all active subscriptions & streams
func (*Resolver) MergeBufPairData ¶
func (*Resolver) MergeBufPairErrors ¶
func (*Resolver) MergeBufPairs ¶
func (*Resolver) ResolveGraphQLResponse ¶
func (*Resolver) ResolveGraphQLResponsePatch ¶
func (*Resolver) ResolveGraphQLStreamingResponse ¶
func (r *Resolver) ResolveGraphQLStreamingResponse(ctx *Context, response *GraphQLStreamingResponse, data []byte, writer FlushWriter) (err error)
func (*Resolver) ResolveGraphQLSubscription ¶
func (r *Resolver) ResolveGraphQLSubscription(ctx *Context, subscription *GraphQLSubscription, writer FlushWriter) (err error)
type SegmentType ¶
type SegmentType int
const ( StaticSegmentType SegmentType = iota + 1 VariableSegmentType )
type SingleFetch ¶
type SingleFetch struct { BufferId int Input string DataSource DataSource Variables Variables // DisallowSingleFlight is used for write operations like mutations, POST, DELETE etc. to disable singleFlight // By default SingleFlight for fetches is disabled and needs to be enabled on the Resolver first // If the resolver allows SingleFlight it's up the each individual DataSource Planner to decide whether an Operation // should be allowed to use SingleFlight DisallowSingleFlight bool DisableDataLoader bool InputTemplate InputTemplate DataSourceIdentifier []byte ProcessResponseConfig ProcessResponseConfig }
func (*SingleFetch) FetchKind ¶
func (_ *SingleFetch) FetchKind() FetchKind
type StreamField ¶
type StreamField struct {
InitialBatchSize int
}
type String ¶
type String struct { Path []string Nullable bool Export *FieldExport }
type SubscriptionDataSource ¶ added in v1.21.0
type TemplateSegment ¶
type TemplateSegment struct { SegmentType SegmentType Data []byte VariableKind VariableKind VariableSourcePath []string Renderer VariableRenderer }
type Variable ¶
type Variable interface { GetVariableKind() VariableKind Equals(another Variable) bool TemplateSegment() TemplateSegment }
type VariableKind ¶
type VariableKind int
const ( ContextVariableKind VariableKind = iota + 1 ObjectVariableKind HeaderVariableKind )
type VariableRenderer ¶ added in v1.37.0
type VariableRenderer interface {
RenderVariable(ctx context.Context, data []byte, out io.Writer) error
}
VariableRenderer is the interface to allow custom implementations of rendering Variables Depending on where a Variable is being used, a different method for rendering is required E.g. a Variable needs to be rendered conforming to the GraphQL specification, when used within a GraphQL Query If a Variable is used within a JSON Object, the contents need to be rendered as a JSON Object
type VariableSchema ¶ added in v1.37.0
type VariableSchema struct { }