Documentation ¶
Index ¶
- Constants
- Variables
- func ConfigJson(config Configuration) json.RawMessage
- func EntityInterfacesPlanConfiguration(factory plan.PlannerFactory) *plan.Configuration
- type Configuration
- type ConnectionHandler
- type DefaultSubscriptionClientFactory
- type Factory
- type FederationConfiguration
- type FetchConfiguration
- type GraphQLBody
- type GraphQLSubscriptionClient
- type GraphQLSubscriptionClientFactory
- type GraphQLSubscriptionOptions
- type OnWsConnectionInitCallback
- type Options
- type Planner
- func (p *Planner) ConfigureFetch() resolve.FetchConfiguration
- func (p *Planner) ConfigureSubscription() plan.SubscriptionConfiguration
- func (p *Planner) DataSourcePlanningBehavior() plan.DataSourcePlanningBehavior
- func (p *Planner) DebugPrint(args ...interface{})
- func (p *Planner) DownstreamResponseFieldAlias(downstreamFieldRef int) (alias string, exists bool)
- func (p *Planner) EnableDebug()
- func (p *Planner) EnableQueryPlanLogging()
- func (p *Planner) EnterArgument(_ int)
- func (p *Planner) EnterDirective(ref int)
- func (p *Planner) EnterDocument(_, _ *ast.Document)
- func (p *Planner) EnterField(ref int)
- func (p *Planner) EnterInlineFragment(ref int)
- func (p *Planner) EnterOperationDefinition(ref int)
- func (p *Planner) EnterSelectionSet(ref int)
- func (p *Planner) EnterVariableDefinition(ref int)
- func (p *Planner) ID() (id int)
- func (p *Planner) LeaveDocument(_, _ *ast.Document)
- func (p *Planner) LeaveField(ref int)
- func (p *Planner) LeaveInlineFragment(ref int)
- func (p *Planner) LeaveOperationDefinition(_ int)
- func (p *Planner) LeaveSelectionSet(ref int)
- func (p *Planner) LeaveVariableDefinition(_ int)
- func (p *Planner) Register(visitor *plan.Visitor, configuration plan.DataSourceConfiguration, ...) error
- func (p *Planner) SetID(id int)
- func (p *Planner) UpstreamSchema(dataSourceConfig plan.DataSourceConfiguration) *ast.Document
- type SingleTypeField
- type Source
- type Subscription
- type SubscriptionClient
- type SubscriptionConfiguration
- type SubscriptionSource
Constants ¶
const EntityInterfacesDefinition = `` /* 696-byte string literal not displayed */
const (
ProtocolGraphQLTWS = "graphql-transport-ws"
)
websocket sub-protocol: https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.md
const (
ProtocolGraphQLWS = "graphql-ws"
)
websocket sub-protocol: https://github.com/apollographql/subscriptions-transport-ws/blob/master/PROTOCOL.md
Variables ¶
var ( DefaultPostProcessingConfiguration = resolve.PostProcessingConfiguration{ SelectResponseDataPath: []string{"data"}, SelectResponseErrorsPath: []string{"errors"}, } EntitiesPostProcessingConfiguration = resolve.PostProcessingConfiguration{ SelectResponseDataPath: []string{"data", "_entities"}, SelectResponseErrorsPath: []string{"errors"}, } SingleEntityPostProcessingConfiguration = resolve.PostProcessingConfiguration{ SelectResponseDataPath: []string{"data", "_entities", "[0]"}, SelectResponseErrorsPath: []string{"errors"}, } )
Functions ¶
func ConfigJson ¶
func ConfigJson(config Configuration) json.RawMessage
func EntityInterfacesPlanConfiguration ¶
func EntityInterfacesPlanConfiguration(factory plan.PlannerFactory) *plan.Configuration
Types ¶
type Configuration ¶
type Configuration struct { Fetch FetchConfiguration Subscription SubscriptionConfiguration Federation FederationConfiguration UpstreamSchema string CustomScalarTypeFields []SingleTypeField }
func (*Configuration) ApplyDefaults ¶
func (c *Configuration) ApplyDefaults()
type ConnectionHandler ¶
type ConnectionHandler interface { StartBlocking(sub Subscription) SubscribeCH() chan<- Subscription }
type DefaultSubscriptionClientFactory ¶
type DefaultSubscriptionClientFactory struct{}
func (*DefaultSubscriptionClientFactory) NewSubscriptionClient ¶
func (d *DefaultSubscriptionClientFactory) NewSubscriptionClient(httpClient, streamingClient *http.Client, engineCtx context.Context, options ...Options) GraphQLSubscriptionClient
type Factory ¶
type Factory struct { HTTPClient *http.Client StreamingClient *http.Client OnWsConnectionInitCallback *OnWsConnectionInitCallback SubscriptionClient *SubscriptionClient Logger abstractlogger.Logger }
type FederationConfiguration ¶
type FetchConfiguration ¶
type GraphQLBody ¶
type GraphQLBody struct { Query string `json:"query,omitempty"` OperationName string `json:"operationName,omitempty"` Variables json.RawMessage `json:"variables,omitempty"` Extensions json.RawMessage `json:"extensions,omitempty"` }
type GraphQLSubscriptionClient ¶
type GraphQLSubscriptionClient interface { Subscribe(ctx *resolve.Context, options GraphQLSubscriptionOptions, updater resolve.SubscriptionUpdater) error UniqueRequestID(ctx *resolve.Context, options GraphQLSubscriptionOptions, hash *xxhash.Digest) (err error) }
type GraphQLSubscriptionClientFactory ¶
type GraphQLSubscriptionClientFactory interface {
NewSubscriptionClient(httpClient, streamingClient *http.Client, engineCtx context.Context, options ...Options) GraphQLSubscriptionClient
}
GraphQLSubscriptionClientFactory abstracts the way of creating a new GraphQLSubscriptionClient. This can be very handy for testing purposes.
type GraphQLSubscriptionOptions ¶
type GraphQLSubscriptionOptions struct { URL string `json:"url"` InitialPayload json.RawMessage `json:"initial_payload"` Body GraphQLBody `json:"body"` Header http.Header `json:"header"` UseSSE bool `json:"use_sse"` SSEMethodPost bool `json:"sse_method_post"` ForwardedClientHeaderNames []string `json:"forwarded_client_header_names"` ForwardedClientHeaderRegularExpressions []*regexp.Regexp `json:"forwarded_client_header_regular_expressions"` }
type Options ¶
type Options func(options *opts)
func WithLogger ¶
func WithLogger(log abstractlogger.Logger) Options
func WithOnWsConnectionInitCallback ¶
func WithOnWsConnectionInitCallback(callback *OnWsConnectionInitCallback) Options
func WithReadTimeout ¶
func WithWSSubProtocol ¶
type Planner ¶
type Planner struct {
// contains filtered or unexported fields
}
func (*Planner) ConfigureFetch ¶
func (p *Planner) ConfigureFetch() resolve.FetchConfiguration
func (*Planner) ConfigureSubscription ¶
func (p *Planner) ConfigureSubscription() plan.SubscriptionConfiguration
func (*Planner) DataSourcePlanningBehavior ¶
func (p *Planner) DataSourcePlanningBehavior() plan.DataSourcePlanningBehavior
func (*Planner) DebugPrint ¶
func (p *Planner) DebugPrint(args ...interface{})
func (*Planner) DownstreamResponseFieldAlias ¶
func (*Planner) EnableDebug ¶
func (p *Planner) EnableDebug()
func (*Planner) EnableQueryPlanLogging ¶
func (p *Planner) EnableQueryPlanLogging()
func (*Planner) EnterArgument ¶
func (*Planner) EnterDirective ¶
func (*Planner) EnterDocument ¶
func (*Planner) EnterField ¶
func (*Planner) EnterInlineFragment ¶
func (*Planner) EnterOperationDefinition ¶
func (*Planner) EnterSelectionSet ¶
func (*Planner) EnterVariableDefinition ¶
func (*Planner) LeaveDocument ¶
func (*Planner) LeaveField ¶
func (*Planner) LeaveInlineFragment ¶
func (*Planner) LeaveOperationDefinition ¶
func (*Planner) LeaveSelectionSet ¶
func (*Planner) LeaveVariableDefinition ¶
func (*Planner) Register ¶
func (p *Planner) Register(visitor *plan.Visitor, configuration plan.DataSourceConfiguration, dataSourcePlannerConfiguration plan.DataSourcePlannerConfiguration) error
func (*Planner) UpstreamSchema ¶
func (p *Planner) UpstreamSchema(dataSourceConfig plan.DataSourceConfiguration) *ast.Document
type SingleTypeField ¶
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
type SubscriptionClient ¶
type SubscriptionClient struct {
// contains filtered or unexported fields
}
SubscriptionClient allows running multiple subscriptions via the same WebSocket either SSE connection It takes care of de-duplicating connections to the same origin under certain circumstances If Hash(URL,Body,Headers) result in the same result, an existing connection is re-used
func (*SubscriptionClient) Subscribe ¶
func (c *SubscriptionClient) Subscribe(reqCtx *resolve.Context, options GraphQLSubscriptionOptions, updater resolve.SubscriptionUpdater) error
Subscribe initiates a new GraphQL Subscription with the origin If an existing WS connection with the same ID (Hash) exists, it is being re-used If connection protocol is SSE, a new connection is always created If no connection exists, the client initiates a new one
func (*SubscriptionClient) UniqueRequestID ¶
func (c *SubscriptionClient) UniqueRequestID(ctx *resolve.Context, options GraphQLSubscriptionOptions, hash *xxhash.Digest) (err error)
type SubscriptionConfiguration ¶
type SubscriptionConfiguration struct { URL string UseSSE bool SSEMethodPost bool // ForwardedClientHeaderNames indicates headers names that might be forwarded from the // client to the upstream server. This is used to determine which connections // can be multiplexed together, but the subscription engine does not forward // these headers by itself. ForwardedClientHeaderNames []string // ForwardedClientHeaderRegularExpressions regular expressions that if matched to the header // name might be forwarded from the client to the upstream server. This is used to determine // which connections can be multiplexed together, but the subscription engine does not forward // these headers by itself. ForwardedClientHeaderRegularExpressions []*regexp.Regexp }
type SubscriptionSource ¶
type SubscriptionSource struct {
// contains filtered or unexported fields
}
func (*SubscriptionSource) Start ¶
func (s *SubscriptionSource) Start(ctx *resolve.Context, input []byte, updater resolve.SubscriptionUpdater) error
func (*SubscriptionSource) UniqueRequestID ¶
func (s *SubscriptionSource) UniqueRequestID(ctx *resolve.Context, input []byte, xxh *xxhash.Digest) (err error)