Documentation
¶
Index ¶
- Constants
- Variables
- func GetDurationNanoSinceTraceStart(ctx context.Context) int64
- func IsIntrospectionDataSource(dataSourceID string) bool
- func SetInputUndefinedVariables(preparedInput *bytes.Buffer, undefinedVariables []string) error
- func SetNormalizeStats(ctx context.Context, stats PhaseStats)
- func SetParseStats(ctx context.Context, stats PhaseStats)
- func SetPlannerStats(ctx context.Context, stats PhaseStats)
- func SetRequest(ctx context.Context, r *RequestData) context.Context
- func SetTraceStart(ctx context.Context, predictableDebugTimings bool) context.Context
- func SetValidateStats(ctx context.Context, stats PhaseStats)
- func SingleFlightDisallowed(ctx context.Context) bool
- type Array
- type AsyncErrorWriter
- type AsyncSubscriptionDataSource
- type AuthorizationDeny
- type Authorizer
- type BatchEntityFetch
- type BatchInput
- type BigInt
- type BodyData
- type Boolean
- type BufPair
- type CSVVariableRenderer
- type ConnectDoneStats
- type ConnectStartStats
- type Context
- func (c *Context) Context() context.Context
- func (c *Context) Free()
- func (c *Context) SetAuthorizer(authorizer Authorizer)
- func (c *Context) SetEngineLoaderHooks(hooks LoaderHooks)
- func (c *Context) SetRateLimiter(limiter RateLimiter)
- func (c *Context) SubgraphErrors() error
- func (c *Context) WithContext(ctx context.Context) *Context
- type ContextVariable
- type CustomNode
- type CustomResolve
- type DNSDoneStats
- type DNSStartStats
- type DataSource
- type DataSourceInfo
- type DataSourceLoadTrace
- type DeferField
- type EmptyArray
- type EmptyObject
- type EntityFetch
- type EntityInput
- type Enum
- type ErrMergeResult
- type ExecutionOptions
- type Fetch
- type FetchConfiguration
- type FetchDependencies
- type FetchInfo
- type FetchItem
- type FetchItemPathElement
- type FetchItemPathElementKind
- type FetchKind
- type FetchTraceNode
- type FetchTreeNode
- type FetchTreeNodeKind
- type FetchTreeQueryPlan
- type FetchTreeQueryPlanNode
- type FetchTreeTraceNode
- type Field
- type FieldExport
- type FieldInfo
- type Float
- type GetConnStats
- type GotConnStats
- type GotFirstResponseByteStats
- type GraphCoordinate
- type GraphQLError
- type GraphQLResolveInfo
- type GraphQLResponse
- type GraphQLResponseInfo
- type GraphQLSubscription
- type GraphQLSubscriptionTrigger
- type GraphQLVariableRenderer
- type GraphQLVariableResolveRenderer
- type HeaderVariable
- type InputTemplate
- type Integer
- type JSONVariableRenderer
- type JsonRootType
- type JsonRootTypeKind
- type LoadStats
- type Loader
- type LoaderHooks
- type Location
- type Node
- type NodeKind
- type Null
- type Object
- type ObjectVariable
- type ParallelListItemFetch
- type ParentOnTypeNames
- type PhaseStats
- type PlainVariableRenderer
- type PlanPrinter
- type Position
- type PostProcessingConfiguration
- type QueryPlan
- type RateLimitDeny
- type RateLimitError
- type RateLimitErrorExtensionCode
- type RateLimitOptions
- type RateLimiter
- type RenameTypeName
- type Reporter
- type Representation
- type RepresentationKind
- type Request
- type RequestData
- type Resolvable
- func (r *Resolvable) Init(ctx *Context, initialData []byte, operationType ast.OperationType) (err error)
- func (r *Resolvable) InitSubscription(ctx *Context, initialData []byte, postProcessing PostProcessingConfiguration) (err error)
- func (r *Resolvable) Reset()
- func (r *Resolvable) Resolve(ctx context.Context, rootData *Object, fetchTree *FetchTreeNode, out io.Writer) error
- func (r *Resolvable) ResolveNode(node Node, data *astjson.Value, out io.Writer) error
- func (r *Resolvable) WroteErrorsWithoutData() bool
- type ResolvableObjectVariable
- type ResolvableOptions
- type Resolver
- func (r *Resolver) AsyncResolveGraphQLSubscription(ctx *Context, subscription *GraphQLSubscription, ...) (err error)
- func (r *Resolver) AsyncUnsubscribeClient(connectionID int64) error
- func (r *Resolver) AsyncUnsubscribeSubscription(id SubscriptionIdentifier) error
- func (r *Resolver) ResolveGraphQLResponse(ctx *Context, response *GraphQLResponse, data []byte, writer io.Writer) (*GraphQLResolveInfo, error)
- func (r *Resolver) ResolveGraphQLSubscription(ctx *Context, subscription *GraphQLSubscription, ...) error
- func (r *Resolver) SetAsyncErrorWriter(w AsyncErrorWriter)
- type ResolverOptions
- type ResponseInfo
- type ResponseWriter
- type Scalar
- type SegmentType
- type SingleFetch
- type SingleFlightStats
- type StaticString
- type StreamField
- type String
- type SubgraphError
- type SubgraphErrorPropagationMode
- type SubscriptionDataSource
- type SubscriptionFieldFilter
- type SubscriptionFilter
- type SubscriptionIdentifier
- type SubscriptionResponseWriter
- type SubscriptionUpdater
- type TLSHandshakeDoneStats
- type TLSHandshakeStartStats
- type TemplateSegment
- type TraceData
- type TraceInfo
- type TraceOptions
- type TypeFieldSource
- type Variable
- type VariableKind
- type VariableRenderer
- type Variables
- type WroteHeadersStats
- type WroteRequestStats
Constants ¶
const ( IntrospectionSchemaTypeDataSourceID = "introspection__schema&__type" IntrospectionTypeFieldsDataSourceID = "introspection__type__fields" IntrospectionTypeEnumValuesDataSourceID = "introspection__type__enumValues" )
const ( VariableRendererKindPlain = "plain" VariableRendererKindJson = "json" VariableRendererKindGraphqlWithValidation = "graphqlWithValidation" VariableRendererKindGraphqlResolve = "graphqlResolve" VariableRendererKindCsv = "csv" )
const (
DefaultHeartbeatInterval = 5 * time.Second
)
Variables ¶
var (
ErrUnableToResolve = errors.New("unable to resolve operation")
)
var (
InvalidSubscriptionFilterTemplate = fmt.Errorf("invalid subscription filter template")
)
Functions ¶
func SetNormalizeStats ¶
func SetNormalizeStats(ctx context.Context, stats PhaseStats)
func SetParseStats ¶
func SetParseStats(ctx context.Context, stats PhaseStats)
func SetPlannerStats ¶
func SetPlannerStats(ctx context.Context, stats PhaseStats)
func SetRequest ¶
func SetRequest(ctx context.Context, r *RequestData) context.Context
func SetTraceStart ¶
func SetValidateStats ¶
func SetValidateStats(ctx context.Context, stats PhaseStats)
func SingleFlightDisallowed ¶
Types ¶
type Array ¶
func (*Array) NodeNullable ¶
type AsyncErrorWriter ¶
type AsyncErrorWriter interface {
WriteError(ctx *Context, err error, res *GraphQLResponse, w io.Writer)
}
type AuthorizationDeny ¶
type AuthorizationDeny struct {
Reason string
}
type Authorizer ¶
type Authorizer interface {
// AuthorizePreFetch is called prior to making a fetch in the loader
// This allows to implement policies to prevent fetches to an origin
// E.g. for Mutations, it might be undesired to just filter out the response
// You'd want to prevent sending the Operation to the Origin completely
//
// The input argument is the final render of the datasource input
AuthorizePreFetch(ctx *Context, dataSourceID string, input json.RawMessage, coordinate GraphCoordinate) (result *AuthorizationDeny, err error)
// AuthorizeObjectField operates on the response and can solely be used to implement policies to filter out response fields
// In contrast to AuthorizePreFetch, this cannot be used to prevent origin requests
// This function only allows you to filter the response before rendering it to the client
//
// The object argument is the flat render of the field-enclosing response object
// Flat render means, we're only rendering scalars, not arrays or objects
AuthorizeObjectField(ctx *Context, dataSourceID string, object json.RawMessage, coordinate GraphCoordinate) (result *AuthorizationDeny, err error)
HasResponseExtensionData(ctx *Context) bool
RenderResponseExtension(ctx *Context, out io.Writer) error
}
type BatchEntityFetch ¶
type BatchEntityFetch struct {
FetchDependencies
Input BatchInput
DataSource DataSource
PostProcessing PostProcessingConfiguration
DataSourceIdentifier []byte
Trace *DataSourceLoadTrace
Info *FetchInfo
}
BatchEntityFetch - represents nested entity fetch on array field allows to join nested fetches to the same subgraph into a single fetch representations variable will contain multiple items according to amount of entities matching this query
func (*BatchEntityFetch) DataSourceInfo ¶
func (b *BatchEntityFetch) DataSourceInfo() DataSourceInfo
func (*BatchEntityFetch) Dependencies ¶
func (b *BatchEntityFetch) Dependencies() FetchDependencies
func (*BatchEntityFetch) FetchKind ¶
func (_ *BatchEntityFetch) FetchKind() FetchKind
type BatchInput ¶
type BatchInput struct {
Header InputTemplate
Items []InputTemplate
// If SkipNullItems is set to true, items that render to null will not be included in the batch but skipped
SkipNullItems bool
// Same as SkipNullItems but for empty objects
SkipEmptyObjectItems bool
// If SkipErrItems is set to true, items that return an error during rendering will not be included in the batch but skipped
// In this case, the error will be swallowed
// E.g. if a field is not nullable and the value is null, the item will be skipped
SkipErrItems bool
Separator InputTemplate
}
type BigInt ¶
type BigInt struct {
Path []string
Nullable bool
Export *FieldExport `json:"export,omitempty"`
}
func (*BigInt) NodeNullable ¶
type BodyData ¶
type BodyData struct {
Query string `json:"query,omitempty"`
OperationName string `json:"operationName,omitempty"`
Variables json.RawMessage `json:"variables,omitempty"`
}
type Boolean ¶
type Boolean struct {
Path []string
Nullable bool
Export *FieldExport `json:"export,omitempty"`
}
func (*Boolean) NodeNullable ¶
type BufPair ¶
type BufPair struct {
Data *fastbuffer.FastBuffer
Errors *fastbuffer.FastBuffer
}
func NewBufPair ¶
func NewBufPair() *BufPair
type CSVVariableRenderer ¶
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 ¶
func NewCSVVariableRenderer(arrayValueType JsonRootType) *CSVVariableRenderer
func NewCSVVariableRendererFromTypeRef ¶
func NewCSVVariableRendererFromTypeRef(operation, definition *ast.Document, variableTypeRef int) *CSVVariableRenderer
func (*CSVVariableRenderer) GetKind ¶
func (c *CSVVariableRenderer) GetKind() string
func (*CSVVariableRenderer) RenderVariable ¶
type ConnectDoneStats ¶
type ConnectStartStats ¶
type Context ¶
type Context struct {
Variables *astjson.Value
Files []httpclient.File
Request Request
RenameTypeNames []RenameTypeName
RemapVariables map[string]string
TracingOptions TraceOptions
RateLimitOptions RateLimitOptions
ExecutionOptions ExecutionOptions
InitialPayload []byte
Extensions []byte
LoaderHooks LoaderHooks
// contains filtered or unexported fields
}
func NewContext ¶
func (*Context) SetAuthorizer ¶
func (c *Context) SetAuthorizer(authorizer Authorizer)
func (*Context) SetEngineLoaderHooks ¶
func (c *Context) SetEngineLoaderHooks(hooks LoaderHooks)
func (*Context) SetRateLimiter ¶
func (c *Context) SetRateLimiter(limiter RateLimiter)
func (*Context) SubgraphErrors ¶
type ContextVariable ¶
type ContextVariable struct {
Path []string
Renderer VariableRenderer
}
func (*ContextVariable) Equals ¶
func (c *ContextVariable) Equals(another Variable) bool
func (*ContextVariable) GetVariableKind ¶
func (_ *ContextVariable) GetVariableKind() VariableKind
func (*ContextVariable) TemplateSegment ¶
func (c *ContextVariable) TemplateSegment() TemplateSegment
type CustomNode ¶
type CustomNode struct {
CustomResolve
Nullable bool
Path []string
}
func (*CustomNode) Copy ¶
func (c *CustomNode) Copy() Node
func (*CustomNode) Equals ¶
func (c *CustomNode) Equals(n Node) bool
func (*CustomNode) NodeKind ¶
func (_ *CustomNode) NodeKind() NodeKind
func (*CustomNode) NodeNullable ¶
func (c *CustomNode) NodeNullable() bool
func (*CustomNode) NodePath ¶
func (c *CustomNode) NodePath() []string
type CustomResolve ¶
type DNSDoneStats ¶
type DNSStartStats ¶
type DataSource ¶
type DataSourceInfo ¶
type DataSourceLoadTrace ¶
type DataSourceLoadTrace struct {
RawInputData json.RawMessage `json:"raw_input_data,omitempty"`
Input json.RawMessage `json:"input,omitempty"`
Output json.RawMessage `json:"output,omitempty"`
LoadError string `json:"error,omitempty"`
DurationSinceStartNano int64 `json:"duration_since_start_nanoseconds,omitempty"`
DurationSinceStartPretty string `json:"duration_since_start_pretty,omitempty"`
DurationLoadNano int64 `json:"duration_load_nanoseconds,omitempty"`
DurationLoadPretty string `json:"duration_load_pretty,omitempty"`
SingleFlightUsed bool `json:"single_flight_used"`
LoadSkipped bool `json:"load_skipped"`
LoadStats *LoadStats `json:"load_stats,omitempty"`
Path string `json:"-"`
}
type DeferField ¶
type DeferField struct{}
type EmptyArray ¶
type EmptyArray struct{}
func (*EmptyArray) Copy ¶
func (_ *EmptyArray) Copy() Node
func (*EmptyArray) Equals ¶
func (_ *EmptyArray) Equals(n Node) bool
func (*EmptyArray) NodeKind ¶
func (_ *EmptyArray) NodeKind() NodeKind
func (*EmptyArray) NodeNullable ¶
func (_ *EmptyArray) NodeNullable() bool
func (*EmptyArray) NodePath ¶
func (_ *EmptyArray) NodePath() []string
type EmptyObject ¶
type EmptyObject struct{}
func (*EmptyObject) Copy ¶
func (_ *EmptyObject) Copy() Node
func (*EmptyObject) Equals ¶
func (_ *EmptyObject) Equals(n Node) bool
func (*EmptyObject) NodeKind ¶
func (_ *EmptyObject) NodeKind() NodeKind
func (*EmptyObject) NodeNullable ¶
func (_ *EmptyObject) NodeNullable() bool
func (*EmptyObject) NodePath ¶
func (_ *EmptyObject) NodePath() []string
type EntityFetch ¶
type EntityFetch struct {
FetchDependencies
Input EntityInput
DataSource DataSource
PostProcessing PostProcessingConfiguration
DataSourceIdentifier []byte
Trace *DataSourceLoadTrace
Info *FetchInfo
}
EntityFetch - represents nested entity fetch on object field representations variable will contain single item
func (*EntityFetch) DataSourceInfo ¶
func (e *EntityFetch) DataSourceInfo() DataSourceInfo
func (*EntityFetch) Dependencies ¶
func (e *EntityFetch) Dependencies() FetchDependencies
func (*EntityFetch) FetchKind ¶
func (_ *EntityFetch) FetchKind() FetchKind
type EntityInput ¶
type EntityInput struct {
Header InputTemplate
Item InputTemplate
SkipErrItem bool
}
type Enum ¶
type Enum struct {
Path []string
Nullable bool
Export *FieldExport `json:"export,omitempty"`
TypeName string
Values []string
InaccessibleValues []string
}
func (*Enum) NodeNullable ¶
type ErrMergeResult ¶
func (ErrMergeResult) Error ¶
func (e ErrMergeResult) Error() string
type ExecutionOptions ¶
type Fetch ¶
type Fetch interface {
FetchKind() FetchKind
Dependencies() FetchDependencies
DataSourceInfo() DataSourceInfo
}
type FetchConfiguration ¶
type FetchConfiguration struct {
Input string
Variables Variables
DataSource DataSource
// RequiresParallelListItemFetch is used to indicate that the single fetches should be executed without batching
// When we have multiple fetches attached to the object - after post-processing of a plan we will get ParallelListItemFetch instead of ParallelFetch
RequiresParallelListItemFetch bool
// RequiresEntityFetch will be set to true if the fetch is an entity fetch on an object. After post-processing, we will get EntityFetch
RequiresEntityFetch bool
// RequiresEntityBatchFetch indicates that entity fetches on array items could be batched. After post-processing, we will get EntityBatchFetch
RequiresEntityBatchFetch bool
PostProcessing PostProcessingConfiguration
// SetTemplateOutputToNullOnVariableNull will safely return "null" if one of the template variables renders to null
// This is the case, e.g. when using batching and one sibling is null, resulting in a null value for one batch item
// Returning null in this case tells the batch implementation to skip this item
SetTemplateOutputToNullOnVariableNull bool
QueryPlan *QueryPlan
}
func (*FetchConfiguration) Equals ¶
func (fc *FetchConfiguration) Equals(other *FetchConfiguration) bool
type FetchDependencies ¶
FetchDependencies holding current fetch id and ids of fetches that current fetch depends on e.g. should be fetched only after all dependent fetches are fetched
type FetchInfo ¶
type FetchInfo struct {
DataSourceID string
DataSourceName string
RootFields []GraphCoordinate
OperationType ast.OperationType
QueryPlan *QueryPlan
}
type FetchItem ¶
type FetchItem struct {
Fetch Fetch
FetchPath []FetchItemPathElement
ResponsePath string
ResponsePathElements []string
}
type FetchItemPathElement ¶
type FetchItemPathElement struct {
Kind FetchItemPathElementKind
Path []string
}
func ArrayPath ¶
func ArrayPath(path ...string) FetchItemPathElement
func ObjectPath ¶
func ObjectPath(path ...string) FetchItemPathElement
type FetchItemPathElementKind ¶
type FetchItemPathElementKind string
const ( FetchItemPathElementKindObject FetchItemPathElementKind = "object" FetchItemPathElementKindArray FetchItemPathElementKind = "array" )
type FetchTraceNode ¶
type FetchTraceNode struct {
Kind string `json:"kind"`
Path string `json:"path"`
SourceID string `json:"source_id"`
SourceName string `json:"source_name"`
Trace *DataSourceLoadTrace `json:"trace,omitempty"`
Traces []*DataSourceLoadTrace `json:"traces,omitempty"`
}
type FetchTreeNode ¶
type FetchTreeNode struct {
Kind FetchTreeNodeKind `json:"kind"`
// Only set for subscription
Trigger *FetchTreeNode `json:"trigger"`
Item *FetchItem `json:"item"`
ChildNodes []*FetchTreeNode `json:"child_nodes"`
NormalizedQuery string `json:"normalized_query"`
}
func Parallel ¶
func Parallel(children ...*FetchTreeNode) *FetchTreeNode
func Sequence ¶
func Sequence(children ...*FetchTreeNode) *FetchTreeNode
func Single ¶
func Single(fetch Fetch, path ...FetchItemPathElement) *FetchTreeNode
func SingleWithPath ¶
func SingleWithPath(fetch Fetch, responsePath string, path ...FetchItemPathElement) *FetchTreeNode
func (*FetchTreeNode) QueryPlan ¶
func (n *FetchTreeNode) QueryPlan() *FetchTreeQueryPlanNode
func (*FetchTreeNode) Trace ¶
func (n *FetchTreeNode) Trace() *FetchTreeTraceNode
type FetchTreeNodeKind ¶
type FetchTreeNodeKind string
const ( FetchTreeNodeKindSingle FetchTreeNodeKind = "Single" FetchTreeNodeKindSequence FetchTreeNodeKind = "Sequence" FetchTreeNodeKindParallel FetchTreeNodeKind = "Parallel" FetchTreeNodeKindTrigger FetchTreeNodeKind = "Trigger" )
type FetchTreeQueryPlan ¶
type FetchTreeQueryPlan struct {
Kind string `json:"kind"`
Path string `json:"path,omitempty"`
SubgraphName string `json:"subgraphName"`
SubgraphID string `json:"subgraphId"`
FetchID int `json:"fetchId"`
DependsOnFetchIDs []int `json:"dependsOnFetchIds,omitempty"`
Representations []Representation `json:"representations,omitempty"`
Query string `json:"query,omitempty"`
}
type FetchTreeQueryPlanNode ¶
type FetchTreeQueryPlanNode struct {
Version string `json:"version,omitempty"`
Kind FetchTreeNodeKind `json:"kind"`
Trigger *FetchTreeQueryPlan `json:"trigger,omitempty"`
Children []*FetchTreeQueryPlanNode `json:"children,omitempty"`
Fetch *FetchTreeQueryPlan `json:"fetch,omitempty"`
NormalizedQuery string `json:"normalizedQuery,omitempty"`
}
func (*FetchTreeQueryPlanNode) PrettyPrint ¶
func (n *FetchTreeQueryPlanNode) PrettyPrint() string
type FetchTreeTraceNode ¶
type FetchTreeTraceNode struct {
Kind FetchTreeNodeKind `json:"kind"`
Children []*FetchTreeTraceNode `json:"children,omitempty"`
Fetch *FetchTraceNode `json:"fetch,omitempty"`
}
type Field ¶
type Field struct {
Name []byte
Value Node
Position Position
Defer *DeferField
Stream *StreamField
OnTypeNames [][]byte
ParentOnTypeNames []ParentOnTypeNames
Info *FieldInfo
}
type FieldExport ¶
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 FieldInfo ¶
type FieldInfo struct {
// Name is the name of the field.
Name string
ExactParentTypeName string
// ParentTypeNames is the list of possible parent types for this field.
// E.g. for a root field, this will be Query, Mutation, Subscription.
// For a field on an object type, this will be the name of that object type.
// For a field on an interface type, this will be the name of that interface type and all of its possible implementations.
ParentTypeNames []string
// NamedType is the underlying node type of the field.
// E.g. for a field of type Hobby! this will be Hobby.
// For a field of type [Hobby] this will be Hobby.
// For a field of type [Hobby!]! this will be Hobby.
// For scalar fields, this will return string, int, float, boolean, ID.
NamedType string
Source TypeFieldSource
FetchID int
// HasAuthorizationRule needs to be set to true if the Authorizer should be called for this field
HasAuthorizationRule bool
// IndirectInterfaceNames is set to the interfaces name if the field is on a concrete type that implements an interface which wraps it
// It's plural because interfaces and be overlapping with types that implement multiple interfaces
IndirectInterfaceNames []string
}
type Float ¶
type Float struct {
Path []string
Nullable bool
Export *FieldExport `json:"export,omitempty"`
}
func (*Float) NodeNullable ¶
type GetConnStats ¶
type GotConnStats ¶
type GotConnStats struct {
DurationSinceStartNano int64 `json:"duration_since_start_nanoseconds"`
DurationSinceStartPretty string `json:"duration_since_start_pretty"`
Reused bool `json:"reused"`
WasIdle bool `json:"was_idle"`
IdleTimeNano int64 `json:"idle_time_nanoseconds"`
IdleTimePretty string `json:"idle_time_pretty"`
}
type GraphCoordinate ¶
type GraphQLError ¶
type GraphQLResolveInfo ¶
type GraphQLResponse ¶
type GraphQLResponse struct {
Data *Object
RenameTypeNames []RenameTypeName
Info *GraphQLResponseInfo
Fetches *FetchTreeNode
DataSources []DataSourceInfo
}
type GraphQLResponseInfo ¶
type GraphQLResponseInfo struct {
OperationType ast.OperationType
}
type GraphQLSubscription ¶
type GraphQLSubscription struct {
Trigger GraphQLSubscriptionTrigger
Response *GraphQLResponse
Filter *SubscriptionFilter
}
type GraphQLSubscriptionTrigger ¶
type GraphQLSubscriptionTrigger struct {
Input []byte
InputTemplate InputTemplate
Variables Variables
Source SubscriptionDataSource
PostProcessing PostProcessingConfiguration
}
type GraphQLVariableRenderer ¶
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 NewGraphQLVariableRendererFromTypeRefWithoutValidation ¶
func NewGraphQLVariableRendererFromTypeRefWithoutValidation(operation, definition *ast.Document, variableTypeRef int) (*GraphQLVariableRenderer, error)
func (*GraphQLVariableRenderer) GetKind ¶
func (g *GraphQLVariableRenderer) GetKind() string
func (*GraphQLVariableRenderer) RenderVariable ¶
type GraphQLVariableResolveRenderer ¶
func NewGraphQLVariableResolveRenderer ¶
func NewGraphQLVariableResolveRenderer(node Node) *GraphQLVariableResolveRenderer
func (*GraphQLVariableResolveRenderer) GetKind ¶
func (g *GraphQLVariableResolveRenderer) GetKind() string
func (*GraphQLVariableResolveRenderer) RenderVariable ¶
type HeaderVariable ¶
type HeaderVariable struct {
Path []string
}
func (*HeaderVariable) Equals ¶
func (h *HeaderVariable) Equals(another Variable) bool
func (*HeaderVariable) GetVariableKind ¶
func (h *HeaderVariable) GetVariableKind() VariableKind
func (*HeaderVariable) TemplateSegment ¶
func (h *HeaderVariable) TemplateSegment() TemplateSegment
type InputTemplate ¶
type InputTemplate struct {
Segments []TemplateSegment
// SetTemplateOutputToNullOnVariableNull will safely return "null" if one of the template variables renders to null
// This is the case, e.g. when using batching and one sibling is null, resulting in a null value for one batch item
// Returning null in this case tells the batch implementation to skip this item
SetTemplateOutputToNullOnVariableNull bool
}
func (*InputTemplate) RenderAndCollectUndefinedVariables ¶
type Integer ¶
type Integer struct {
Path []string
Nullable bool
Export *FieldExport `json:"export,omitempty"`
}
func (*Integer) NodeNullable ¶
type JSONVariableRenderer ¶
type JSONVariableRenderer struct {
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 ¶
func NewJSONVariableRenderer() *JSONVariableRenderer
func (*JSONVariableRenderer) GetKind ¶
func (r *JSONVariableRenderer) GetKind() string
func (*JSONVariableRenderer) RenderVariable ¶
type JsonRootType ¶
type JsonRootType struct {
Value jsonparser.ValueType
Values []jsonparser.ValueType
Kind JsonRootTypeKind
}
func (JsonRootType) Satisfies ¶
func (t JsonRootType) Satisfies(dataType jsonparser.ValueType) bool
type JsonRootTypeKind ¶
type JsonRootTypeKind int
const ( JsonRootTypeKindSingle JsonRootTypeKind = iota JsonRootTypeKindMultiple )
type LoadStats ¶
type LoadStats struct {
GetConn GetConnStats `json:"get_conn"`
GotConn GotConnStats `json:"got_conn"`
GotFirstResponseByte GotFirstResponseByteStats `json:"got_first_response_byte"`
DNSStart DNSStartStats `json:"dns_start"`
DNSDone DNSDoneStats `json:"dns_done"`
ConnectStart ConnectStartStats `json:"connect_start"`
ConnectDone ConnectDoneStats `json:"connect_done"`
TLSHandshakeStart TLSHandshakeStartStats `json:"tls_handshake_start"`
TLSHandshakeDone TLSHandshakeDoneStats `json:"tls_handshake_done"`
WroteHeaders WroteHeadersStats `json:"wrote_headers"`
WroteRequest WroteRequestStats `json:"wrote_request"`
}
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
func (*Loader) LoadGraphQLResponseData ¶
func (l *Loader) LoadGraphQLResponseData(ctx *Context, response *GraphQLResponse, resolvable *Resolvable) (err error)
type LoaderHooks ¶
type LoaderHooks interface {
// OnLoad is called before the fetch is executed
OnLoad(ctx context.Context, ds DataSourceInfo) context.Context
// OnFinished is called after the fetch has been executed and the response has been processed and merged
OnFinished(ctx context.Context, ds DataSourceInfo, info *ResponseInfo)
}
type Object ¶
type Object struct {
Nullable bool
Path []string
Fields []*Field
Fetches []Fetch
Fetch Fetch
PossibleTypes map[string]struct{} `json:"-"`
SourceName string `json:"-"`
TypeName string `json:"-"`
}
func (*Object) NodeNullable ¶
type ObjectVariable ¶
type ObjectVariable struct {
Path []string
Renderer VariableRenderer
}
func (*ObjectVariable) Equals ¶
func (o *ObjectVariable) Equals(another Variable) bool
func (*ObjectVariable) GetVariableKind ¶
func (o *ObjectVariable) GetVariableKind() VariableKind
func (*ObjectVariable) TemplateSegment ¶
func (o *ObjectVariable) TemplateSegment() TemplateSegment
type ParallelListItemFetch ¶
type ParallelListItemFetch struct {
Fetch *SingleFetch
Traces []*SingleFetch
Trace *DataSourceLoadTrace
}
The ParallelListItemFetch can be used to make nested parallel fetches within a list Usually, you want to batch fetches within a list, which is the default behavior of SingleFetch However, if the data source does not support batching, you can use this fetch to make parallel fetches within a list
func (*ParallelListItemFetch) DataSourceInfo ¶
func (p *ParallelListItemFetch) DataSourceInfo() DataSourceInfo
func (*ParallelListItemFetch) Dependencies ¶
func (p *ParallelListItemFetch) Dependencies() FetchDependencies
func (*ParallelListItemFetch) FetchKind ¶
func (_ *ParallelListItemFetch) FetchKind() FetchKind
type ParentOnTypeNames ¶
type PhaseStats ¶
type PhaseStats struct {
DurationNano int64 `json:"duration_nanoseconds"`
DurationPretty string `json:"duration_pretty"`
DurationSinceStartNano int64 `json:"duration_since_start_nanoseconds"`
DurationSinceStartPretty string `json:"duration_since_start_pretty"`
}
func SetDebugStats ¶
func SetDebugStats(info *TraceInfo, stats PhaseStats, phaseNo int64) PhaseStats
type PlainVariableRenderer ¶
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 ¶
func NewPlainVariableRenderer() *PlainVariableRenderer
func (*PlainVariableRenderer) GetKind ¶
func (p *PlainVariableRenderer) GetKind() string
func (*PlainVariableRenderer) RenderVariable ¶
type PlanPrinter ¶
type PlanPrinter struct {
// contains filtered or unexported fields
}
func (*PlanPrinter) Print ¶
func (p *PlanPrinter) Print(plan *FetchTreeQueryPlanNode) string
type PostProcessingConfiguration ¶
type PostProcessingConfiguration struct {
// SelectResponseDataPath used to make a jsonparser.Get call on the response data
SelectResponseDataPath []string
// SelectResponseErrorsPath is similar to SelectResponseDataPath, but for errors
// If this is set, the response will be considered an error if the jsonparser.Get call returns a non-empty value
// The value will be expected to be a GraphQL error object
SelectResponseErrorsPath []string
// MergePath can be defined to merge the result of the post-processing into the parent object at the given path
// e.g. if the parent is {"a":1}, result is {"foo":"bar"} and the MergePath is ["b"],
// the result will be {"a":1,"b":{"foo":"bar"}}
// If the MergePath is empty, the result will be merged into the parent object
// In this case, the result would be {"a":1,"foo":"bar"}
// This is useful if you make multiple fetches, e.g. parallel fetches, that would otherwise overwrite each other
MergePath []string
}
func (*PostProcessingConfiguration) Equals ¶
func (ppc *PostProcessingConfiguration) Equals(other *PostProcessingConfiguration) bool
Equals compares two PostProcessingConfiguration objects
type QueryPlan ¶
type QueryPlan struct {
DependsOnFields []Representation
Query string
}
type RateLimitDeny ¶
type RateLimitDeny struct {
Reason string
}
type RateLimitError ¶
func NewRateLimitError ¶
func NewRateLimitError(subgraphName, path, reason string) *RateLimitError
func (*RateLimitError) Error ¶
func (e *RateLimitError) Error() string
type RateLimitOptions ¶
type RateLimitOptions struct {
// Enable switches rate limiting on or off
Enable bool
// IncludeStatsInResponseExtension includes the rate limit stats in the response extensions
IncludeStatsInResponseExtension bool
Rate int
Burst int
Period time.Duration
RateLimitKey string
RejectExceedingRequests bool
ErrorExtensionCode RateLimitErrorExtensionCode
}
type RateLimiter ¶
type RateLimiter interface {
RateLimitPreFetch(ctx *Context, info *FetchInfo, input json.RawMessage) (result *RateLimitDeny, err error)
RenderResponseExtension(ctx *Context, out io.Writer) error
}
type RenameTypeName ¶
type RenameTypeName struct {
From, To []byte
}
type Reporter ¶
type Reporter interface {
// SubscriptionUpdateSent called when a new subscription update is sent
SubscriptionUpdateSent()
// SubscriptionCountInc increased when a new subscription is added to a trigger, this includes inflight subscriptions
SubscriptionCountInc(count int)
// SubscriptionCountDec decreased when a subscription is removed from a trigger e.g. on shutdown
SubscriptionCountDec(count int)
// TriggerCountInc increased when a new trigger is added e.g. when a trigger is started and initialized
TriggerCountInc(count int)
// TriggerCountDec decreased when a trigger is removed e.g. when a trigger is shutdown
TriggerCountDec(count int)
}
type Representation ¶
type Representation struct {
Kind RepresentationKind `json:"kind"`
TypeName string `json:"typeName"`
FieldName string `json:"fieldName,omitempty"`
Fragment string `json:"fragment"`
}
type RepresentationKind ¶
type RepresentationKind string
const ( RepresentationKindKey RepresentationKind = "@key" RepresentationKindRequires RepresentationKind = "@requires" )
type RequestData ¶
type RequestData struct {
Method string `json:"method"`
URL string `json:"url"`
Headers http.Header `json:"headers"`
Body BodyData `json:"body,omitempty"`
}
func GetRequest ¶
func GetRequest(ctx context.Context) *RequestData
type Resolvable ¶
type Resolvable struct {
// contains filtered or unexported fields
}
func NewResolvable ¶
func NewResolvable(options ResolvableOptions) *Resolvable
func (*Resolvable) Init ¶
func (r *Resolvable) Init(ctx *Context, initialData []byte, operationType ast.OperationType) (err error)
func (*Resolvable) InitSubscription ¶
func (r *Resolvable) InitSubscription(ctx *Context, initialData []byte, postProcessing PostProcessingConfiguration) (err error)
func (*Resolvable) Reset ¶
func (r *Resolvable) Reset()
func (*Resolvable) Resolve ¶
func (r *Resolvable) Resolve(ctx context.Context, rootData *Object, fetchTree *FetchTreeNode, out io.Writer) error
func (*Resolvable) ResolveNode ¶
func (*Resolvable) WroteErrorsWithoutData ¶
func (r *Resolvable) WroteErrorsWithoutData() bool
type ResolvableObjectVariable ¶
type ResolvableObjectVariable struct {
Renderer *GraphQLVariableResolveRenderer
}
func NewResolvableObjectVariable ¶
func NewResolvableObjectVariable(node *Object) *ResolvableObjectVariable
func (*ResolvableObjectVariable) Equals ¶
func (h *ResolvableObjectVariable) Equals(another Variable) bool
func (*ResolvableObjectVariable) GetVariableKind ¶
func (h *ResolvableObjectVariable) GetVariableKind() VariableKind
func (*ResolvableObjectVariable) TemplateSegment ¶
func (h *ResolvableObjectVariable) TemplateSegment() TemplateSegment
type ResolvableOptions ¶
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
func New ¶
func New(ctx context.Context, options ResolverOptions) *Resolver
New returns a new Resolver, ctx.Done() is used to cancel all active subscriptions & streams
func (*Resolver) AsyncResolveGraphQLSubscription ¶
func (r *Resolver) AsyncResolveGraphQLSubscription(ctx *Context, subscription *GraphQLSubscription, writer SubscriptionResponseWriter, id SubscriptionIdentifier) (err error)
func (*Resolver) AsyncUnsubscribeClient ¶
func (*Resolver) AsyncUnsubscribeSubscription ¶
func (r *Resolver) AsyncUnsubscribeSubscription(id SubscriptionIdentifier) error
func (*Resolver) ResolveGraphQLResponse ¶
func (r *Resolver) ResolveGraphQLResponse(ctx *Context, response *GraphQLResponse, data []byte, writer io.Writer) (*GraphQLResolveInfo, error)
func (*Resolver) ResolveGraphQLSubscription ¶
func (r *Resolver) ResolveGraphQLSubscription(ctx *Context, subscription *GraphQLSubscription, writer SubscriptionResponseWriter) error
func (*Resolver) SetAsyncErrorWriter ¶
func (r *Resolver) SetAsyncErrorWriter(w AsyncErrorWriter)
type ResolverOptions ¶
type ResolverOptions struct {
// MaxConcurrency limits the number of concurrent tool calls which is used to resolve operations.
// The limit is only applied to getToolsWithLimit() calls. Intentionally, we don't use this limit for
// subscription updates to prevent blocking the subscription during a network collapse because a one-to-one
// relation is not given as in the case of single http request. We already enforce concurrency limits through
// the MaxSubscriptionWorkers option that is a semaphore to limit the number of concurrent subscription updates.
//
// If set to 0, no limit is applied
// It is advised to set this to a reasonable value to prevent excessive memory usage
// Each concurrent resolve operation allocates ~50kb of memory
// In addition, there's a limit of how many concurrent requests can be efficiently resolved
// This depends on the number of CPU cores available, the complexity of the operations, and the origin services
MaxConcurrency int
// MaxSubscriptionWorkers limits the concurrency on how many subscription can be added / removed concurrently.
// This does not include subscription updates, for that we have a separate semaphore MaxSubscriptionUpdates.
MaxSubscriptionWorkers int
// MaxSubscriptionUpdates limits the number of concurrent subscription updates that can be sent to the event loop.
MaxSubscriptionUpdates int
Debug bool
Reporter Reporter
AsyncErrorWriter AsyncErrorWriter
// PropagateSubgraphErrors adds Subgraph Errors to the response
PropagateSubgraphErrors bool
// PropagateSubgraphStatusCodes adds the status code of the Subgraph to the extensions field of a Subgraph Error
PropagateSubgraphStatusCodes bool
// SubgraphErrorPropagationMode defines how Subgraph Errors are propagated
// SubgraphErrorPropagationModeWrapped wraps Subgraph Errors in a Subgraph Error to prevent leaking internal information
// SubgraphErrorPropagationModePassThrough passes Subgraph Errors through without modification
SubgraphErrorPropagationMode SubgraphErrorPropagationMode
// RewriteSubgraphErrorPaths rewrites the paths of Subgraph Errors to match the path of the field from the perspective of the client
// This means that nested entity requests will have their paths rewritten from e.g. "_entities.foo.bar" to "person.foo.bar" if the root field above is "person"
RewriteSubgraphErrorPaths bool
// OmitSubgraphErrorLocations omits the locations field of Subgraph Errors
OmitSubgraphErrorLocations bool
// OmitSubgraphErrorExtensions omits the extensions field of Subgraph Errors
OmitSubgraphErrorExtensions bool
// AllowedErrorExtensionFields defines which fields are allowed in the extensions field of a root subgraph error
AllowedErrorExtensionFields []string
// AttachServiceNameToErrorExtensions attaches the service name to the extensions field of a root subgraph error
AttachServiceNameToErrorExtensions bool
// DefaultErrorExtensionCode is the default error code to use for subgraph errors if no code is provided
DefaultErrorExtensionCode string
// MaxRecyclableParserSize limits the size of the Parser that can be recycled back into the Pool.
// If set to 0, no limit is applied
// This helps keep the Heap size more maintainable if you regularly perform large queries.
MaxRecyclableParserSize int
// ResolvableOptions are configuration options for the Resolvable struct
ResolvableOptions ResolvableOptions
// AllowedCustomSubgraphErrorFields defines which fields are allowed in the subgraph error when in passthrough mode
AllowedSubgraphErrorFields []string
// MultipartSubHeartbeatInterval defines the interval in which a heartbeat is sent to all multipart subscriptions
MultipartSubHeartbeatInterval time.Duration
}
type ResponseInfo ¶
type ResponseInfo struct {
StatusCode int
Err error
// Request is the original request that was sent to the subgraph. This should only be used for reading purposes,
// in order to ensure there aren't memory conflicts, and the body will be nil, as it was read already.
Request *http.Request
// ResponseHeaders contains a clone of the headers of the response from the subgraph.
ResponseHeaders http.Header
}
type ResponseWriter ¶
type Scalar ¶
type Scalar struct {
Path []string
Nullable bool
Export *FieldExport `json:"export,omitempty"`
}
func (*Scalar) NodeNullable ¶
type SegmentType ¶
type SegmentType int
const ( StaticSegmentType SegmentType = iota + 1 VariableSegmentType )
type SingleFetch ¶
type SingleFetch struct {
FetchConfiguration
FetchDependencies
InputTemplate InputTemplate
DataSourceIdentifier []byte
Trace *DataSourceLoadTrace
Info *FetchInfo
}
func (*SingleFetch) DataSourceInfo ¶
func (s *SingleFetch) DataSourceInfo() DataSourceInfo
func (*SingleFetch) Dependencies ¶
func (s *SingleFetch) Dependencies() FetchDependencies
func (*SingleFetch) FetchKind ¶
func (_ *SingleFetch) FetchKind() FetchKind
type SingleFlightStats ¶
type SingleFlightStats struct {
SingleFlightUsed bool
}
func GetSingleFlightStats ¶
func GetSingleFlightStats(ctx context.Context) *SingleFlightStats
type StaticString ¶
func (*StaticString) Copy ¶
func (s *StaticString) Copy() Node
func (*StaticString) Equals ¶
func (s *StaticString) Equals(n Node) bool
func (*StaticString) NodeKind ¶
func (_ *StaticString) NodeKind() NodeKind
func (*StaticString) NodeNullable ¶
func (s *StaticString) NodeNullable() bool
func (*StaticString) NodePath ¶
func (s *StaticString) NodePath() []string
type StreamField ¶
type StreamField struct {
InitialBatchSize int
}
type String ¶
type String struct {
Path []string
Nullable bool
Export *FieldExport `json:"export,omitempty"`
UnescapeResponseJson bool `json:"unescape_response_json,omitempty"`
IsTypeName bool `json:"is_type_name,omitempty"`
}
func (*String) NodeNullable ¶
type SubgraphError ¶
type SubgraphError struct {
DataSourceInfo DataSourceInfo
Path string
Reason string
ResponseCode int
DownstreamErrors []*GraphQLError
}
func NewSubgraphError ¶
func NewSubgraphError(ds DataSourceInfo, path, reason string, responseCode int) *SubgraphError
func (*SubgraphError) AppendDownstreamError ¶
func (e *SubgraphError) AppendDownstreamError(error *GraphQLError)
func (*SubgraphError) Codes ¶
func (e *SubgraphError) Codes() []string
func (*SubgraphError) Error ¶
func (e *SubgraphError) Error() string
Error returns the high-level error without downstream errors. For more details, call Summary().
type SubgraphErrorPropagationMode ¶
type SubgraphErrorPropagationMode int
const ( // SubgraphErrorPropagationModeWrapped collects all errors and exposes them as a list of errors on the extensions field "errors" of the gateway error. SubgraphErrorPropagationModeWrapped SubgraphErrorPropagationMode = iota // SubgraphErrorPropagationModePassThrough propagates all errors as root errors as they are. SubgraphErrorPropagationModePassThrough )
type SubscriptionDataSource ¶
type SubscriptionDataSource interface {
// Start is called when a new subscription is created. It establishes the connection to the data source.
// The updater is used to send updates to the client. Deduplication of the request must be done before calling this method.
Start(ctx *Context, input []byte, updater SubscriptionUpdater) error
UniqueRequestID(ctx *Context, input []byte, xxh *xxhash.Digest) (err error)
}
type SubscriptionFieldFilter ¶
type SubscriptionFieldFilter struct {
FieldPath []string
Values []InputTemplate
}
type SubscriptionFilter ¶
type SubscriptionFilter struct {
And []SubscriptionFilter
Or []SubscriptionFilter
Not *SubscriptionFilter
In *SubscriptionFieldFilter
}
type SubscriptionIdentifier ¶
type SubscriptionResponseWriter ¶
type SubscriptionResponseWriter interface {
ResponseWriter
Flush() error
Complete()
}
type SubscriptionUpdater ¶
type SubscriptionUpdater interface {
// Update sends an update to the client. It is not guaranteed that the update is sent immediately.
Update(data []byte)
// Done also takes care of cleaning up the trigger and all subscriptions. No more updates should be sent after calling Done.
Done()
}
type TLSHandshakeDoneStats ¶
type TLSHandshakeStartStats ¶
type TemplateSegment ¶
type TemplateSegment struct {
SegmentType SegmentType
Data []byte
VariableKind VariableKind
VariableSourcePath []string
Renderer VariableRenderer
Segments []TemplateSegment
}
type TraceData ¶
type TraceData struct {
Version string `json:"version"`
Info *TraceInfo `json:"info"`
Fetches *FetchTreeTraceNode `json:"fetches"`
Request *RequestData `json:"request,omitempty"`
}
type TraceInfo ¶
type TraceInfo struct {
TraceStart time.Time `json:"-"`
TraceStartTime string `json:"trace_start_time"`
TraceStartUnix int64 `json:"trace_start_unix"`
ParseStats PhaseStats `json:"parse_stats"`
NormalizeStats PhaseStats `json:"normalize_stats"`
ValidateStats PhaseStats `json:"validate_stats"`
PlannerStats PhaseStats `json:"planner_stats"`
// contains filtered or unexported fields
}
func GetTraceInfo ¶
type TraceOptions ¶
type TraceOptions struct {
// Enable switches tracing on or off
Enable bool
// ExcludeParseStats excludes parse timing information from the trace output
ExcludeParseStats bool
// ExcludeNormalizeStats excludes normalize timing information from the trace output
ExcludeNormalizeStats bool
// ExcludeValidateStats excludes validation timing information from the trace output
ExcludeValidateStats bool
// ExcludePlannerStats excludes planner timing information from the trace output
ExcludePlannerStats bool
// ExcludeRawInputData excludes the raw input for a load operation from the trace output
ExcludeRawInputData bool
// ExcludeInput excludes the rendered input for a load operation from the trace output
ExcludeInput bool
// ExcludeOutput excludes the result of a load operation from the trace output
ExcludeOutput bool
// ExcludeLoadStats excludes the load timing information from the trace output
ExcludeLoadStats bool
// EnablePredictableDebugTimings makes the timings in the trace output predictable for debugging purposes
EnablePredictableDebugTimings bool
// IncludeTraceOutputInResponseExtensions includes the trace output in the response extensions
IncludeTraceOutputInResponseExtensions bool
// Debug makes trace IDs of fetches predictable for debugging purposes
Debug bool
}
func (*TraceOptions) DisableAll ¶
func (r *TraceOptions) DisableAll()
func (*TraceOptions) EnableAll ¶
func (r *TraceOptions) EnableAll()
type TypeFieldSource ¶
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 ResolvableObjectVariableKind ListVariableKind )
type VariableRenderer ¶
type VariableRenderer interface {
GetKind() string
RenderVariable(ctx context.Context, data *astjson.Value, 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