Documentation
¶
Index ¶
- Constants
- Variables
- func EntityInterfacesPlanConfiguration(t *testing.T, factory plan.PlannerFactory[Configuration]) *plan.Configuration
- func EntityInterfacesPlanConfigurationBench(t *testing.B, factory plan.PlannerFactory[Configuration]) *plan.Configuration
- func IsDefaultGraphQLSubscriptionClient(client GraphQLSubscriptionClient) bool
- type Configuration
- type ConfigurationInput
- type ConnectionHandler
- type DefaultSubscriptionClientFactory
- type Factory
- func NewFactory(executionContext context.Context, httpClient *http.Client, ...) (*Factory[Configuration], error)
- func NewFactoryGRPC(executionContext context.Context, grpcClient grpc.ClientConnInterface) (*Factory[Configuration], error)
- func NewFactoryGRPCClientProvider(executionContext context.Context, ...) (*Factory[Configuration], error)
- type FederationConfiguration
- type FetchConfiguration
- type GraphQLBody
- type GraphQLSubscriptionClient
- type GraphQLSubscriptionClientFactory
- type GraphQLSubscriptionOptions
- type InvalidWsSubprotocolError
- type NetPollConfiguration
- type OnWsConnectionInitCallback
- type Options
- func WithFrameTimeout(timeout time.Duration) Options
- func WithLogger(log abstractlogger.Logger) Options
- func WithNetPollConfiguration(config NetPollConfiguration) Options
- func WithPingInterval(interval time.Duration) Options
- func WithPingTimeout(timeout time.Duration) Options
- func WithReadTimeout(timeout time.Duration) Options
- type Planner
- func (p *Planner[T]) ConfigureFetch() resolve.FetchConfiguration
- func (p *Planner[T]) ConfigureSubscription() plan.SubscriptionConfiguration
- func (p *Planner[T]) DataSourcePlanningBehavior() plan.DataSourcePlanningBehavior
- func (p *Planner[T]) DebugPrint(args ...interface{})
- func (p *Planner[T]) DownstreamResponseFieldAlias(downstreamFieldRef int) (alias string, exists bool)
- func (p *Planner[T]) EnableDebug()
- func (p *Planner[T]) EnableDebugQueryPlanLogging()
- func (p *Planner[T]) EnableSubgraphRequestMinifier()
- func (p *Planner[T]) EnterArgument(_ int)
- func (p *Planner[T]) EnterDirective(ref int)
- func (p *Planner[T]) EnterDocument(_, _ *ast.Document)
- func (p *Planner[T]) EnterField(ref int)
- func (p *Planner[T]) EnterInlineFragment(ref int)
- func (p *Planner[T]) EnterOperationDefinition(ref int)
- func (p *Planner[T]) EnterSelectionSet(ref int)
- func (p *Planner[T]) EnterVariableDefinition(ref int)
- func (p *Planner[T]) ID() (id int)
- func (p *Planner[T]) IncludeQueryPlanInFetchConfiguration()
- func (p *Planner[T]) LeaveDocument(_, _ *ast.Document)
- func (p *Planner[T]) LeaveField(ref int)
- func (p *Planner[T]) LeaveInlineFragment(ref int)
- func (p *Planner[T]) LeaveOperationDefinition(_ int)
- func (p *Planner[T]) LeaveSelectionSet(ref int)
- func (p *Planner[T]) LeaveVariableDefinition(_ int)
- func (p *Planner[T]) Register(visitor *plan.Visitor, configuration plan.DataSourceConfiguration[T], ...) error
- func (p *Planner[T]) SetID(id int)
- type SchemaConfiguration
- type SingleTypeField
- type Source
- type SubscriptionConfiguration
- type SubscriptionSource
- func (s *SubscriptionSource) AsyncStart(ctx *resolve.Context, id uint64, input []byte, ...) error
- func (s *SubscriptionSource) AsyncStop(id uint64)
- func (s *SubscriptionSource) Start(ctx *resolve.Context, input []byte, updater resolve.SubscriptionUpdater) error
- func (s *SubscriptionSource) UniqueRequestID(ctx *resolve.Context, input []byte, xxh *xxhash.Digest) (err error)
- type UpgradeRequestError
Constants ¶
const EntityInterfacesDefinition = `` /* 1096-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 EntityInterfacesPlanConfiguration ¶
func EntityInterfacesPlanConfiguration(t *testing.T, factory plan.PlannerFactory[Configuration]) *plan.Configuration
func EntityInterfacesPlanConfigurationBench ¶
func EntityInterfacesPlanConfigurationBench(t *testing.B, factory plan.PlannerFactory[Configuration]) *plan.Configuration
func IsDefaultGraphQLSubscriptionClient ¶
func IsDefaultGraphQLSubscriptionClient(client GraphQLSubscriptionClient) bool
Types ¶
type Configuration ¶
type Configuration struct {
// contains filtered or unexported fields
}
func NewConfiguration ¶
func NewConfiguration(input ConfigurationInput) (Configuration, error)
func (*Configuration) FederationConfiguration ¶
func (c *Configuration) FederationConfiguration() *FederationConfiguration
func (*Configuration) IsFederationEnabled ¶
func (c *Configuration) IsFederationEnabled() bool
func (*Configuration) IsGRPC ¶
func (c *Configuration) IsGRPC() bool
func (*Configuration) UpstreamSchema ¶
func (c *Configuration) UpstreamSchema() (*ast.Document, error)
type ConfigurationInput ¶
type ConfigurationInput struct { Fetch *FetchConfiguration Subscription *SubscriptionConfiguration SchemaConfiguration *SchemaConfiguration CustomScalarTypeFields []SingleTypeField GRPC *grpcdatasource.GRPCConfiguration }
type ConnectionHandler ¶
type ConnectionHandler interface { // StartBlocking starts the connection handler and blocks until the connection is closed // Only used as fallback when epoll is not available StartBlocking() error // HandleMessage handles the incoming message from the connection HandleMessage(data []byte) (done bool) // Ping sends a ping message to the upstream server to keep the connection alive. // Implementers must keep track of the last ping time to initiate a connection shutdown // if the upstream is not sending a pong. Ping() // ServerClose closes the connection from the server side ServerClose() // ClientClose closes the connection from the client side ClientClose() // Subscribe subscribes to the connection Subscribe() error }
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[T Configuration] struct { // contains filtered or unexported fields }
func NewFactory ¶
func NewFactory(executionContext context.Context, httpClient *http.Client, subscriptionClient GraphQLSubscriptionClient) (*Factory[Configuration], error)
NewFactory (HTTP) creates a new factory for the GraphQL datasource planner Graphql Datasource could be stateful in case you are using subscriptions, make sure you are using the same execution context for all datasources
func NewFactoryGRPC ¶
func NewFactoryGRPC(executionContext context.Context, grpcClient grpc.ClientConnInterface) (*Factory[Configuration], error)
NewFactory (GRPC) creates a new factory for the GraphQL datasource planner Graphql Datasource could be stateful in case you are using subscriptions, make sure you are using the same execution context for all datasources
func NewFactoryGRPCClientProvider ¶
func NewFactoryGRPCClientProvider(executionContext context.Context, clientProvider func() grpc.ClientConnInterface) (*Factory[Configuration], error)
NewFactoryGRPCClientProvider creates a new factory for the GraphQL datasource planner This factory is used when the gRPC client is provided by a function. This is useful when you don't want to provide a static client to the factory and let the consumer decide how to provide the client to the datasource. For example when you need to recreate the client in case of a connection error.
func (*Factory[T]) Planner ¶
func (f *Factory[T]) Planner(logger abstractlogger.Logger) plan.DataSourcePlanner[T]
func (*Factory[T]) UpstreamSchema ¶
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 to the origin source. The implementation must not block the calling goroutine. Subscribe(ctx *resolve.Context, options GraphQLSubscriptionOptions, updater resolve.SubscriptionUpdater) error UniqueRequestID(ctx *resolve.Context, options GraphQLSubscriptionOptions, hash *xxhash.Digest) (err error) SubscribeAsync(ctx *resolve.Context, id uint64, options GraphQLSubscriptionOptions, updater resolve.SubscriptionUpdater) error Unsubscribe(id uint64) }
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"` WsSubProtocol string `json:"ws_sub_protocol"` // contains filtered or unexported fields }
type InvalidWsSubprotocolError ¶
type InvalidWsSubprotocolError struct {
InvalidProtocol string
}
func NewInvalidWsSubprotocolError ¶
func NewInvalidWsSubprotocolError(invalidProtocol string) InvalidWsSubprotocolError
func (InvalidWsSubprotocolError) Error ¶
func (e InvalidWsSubprotocolError) Error() string
type NetPollConfiguration ¶
type NetPollConfiguration struct { // Enable can be set to true to enable netPoll Enable bool // BufferSize defines the size of the buffer for the netPoll loop BufferSize int // WaitForNumEvents defines how many events are waited for in the netPoll loop before TickInterval cancels the wait WaitForNumEvents int // MaxEventWorkers defines the parallelism of how many connections can be handled at the same time // The higher the number, the more CPU is used. MaxEventWorkers int // TickInterval defines the time between each netPoll loop when WaitForNumEvents is not reached TickInterval time.Duration }
func (*NetPollConfiguration) ApplyDefaults ¶
func (e *NetPollConfiguration) ApplyDefaults()
type Options ¶
type Options func(options *opts)
func WithFrameTimeout ¶
func WithLogger ¶
func WithLogger(log abstractlogger.Logger) Options
func WithNetPollConfiguration ¶
func WithNetPollConfiguration(config NetPollConfiguration) Options
func WithPingInterval ¶
func WithPingTimeout ¶
func WithReadTimeout ¶
type Planner ¶
type Planner[T Configuration] struct { // contains filtered or unexported fields }
func (*Planner[T]) ConfigureFetch ¶
func (p *Planner[T]) ConfigureFetch() resolve.FetchConfiguration
func (*Planner[T]) ConfigureSubscription ¶
func (p *Planner[T]) ConfigureSubscription() plan.SubscriptionConfiguration
func (*Planner[T]) DataSourcePlanningBehavior ¶
func (p *Planner[T]) DataSourcePlanningBehavior() plan.DataSourcePlanningBehavior
func (*Planner[T]) DebugPrint ¶
func (p *Planner[T]) DebugPrint(args ...interface{})
func (*Planner[T]) DownstreamResponseFieldAlias ¶
func (*Planner[T]) EnableDebug ¶
func (p *Planner[T]) EnableDebug()
func (*Planner[T]) EnableDebugQueryPlanLogging ¶
func (p *Planner[T]) EnableDebugQueryPlanLogging()
func (*Planner[T]) EnableSubgraphRequestMinifier ¶
func (p *Planner[T]) EnableSubgraphRequestMinifier()
func (*Planner[T]) EnterArgument ¶
func (*Planner[T]) EnterDirective ¶
func (*Planner[T]) EnterDocument ¶
func (*Planner[T]) EnterField ¶
func (*Planner[T]) EnterInlineFragment ¶
func (*Planner[T]) EnterOperationDefinition ¶
func (*Planner[T]) EnterSelectionSet ¶
func (*Planner[T]) EnterVariableDefinition ¶
func (*Planner[T]) IncludeQueryPlanInFetchConfiguration ¶
func (p *Planner[T]) IncludeQueryPlanInFetchConfiguration()
func (*Planner[T]) LeaveDocument ¶
func (*Planner[T]) LeaveField ¶
func (*Planner[T]) LeaveInlineFragment ¶
func (*Planner[T]) LeaveOperationDefinition ¶
func (*Planner[T]) LeaveSelectionSet ¶
func (*Planner[T]) LeaveVariableDefinition ¶
func (*Planner[T]) Register ¶
func (p *Planner[T]) Register(visitor *plan.Visitor, configuration plan.DataSourceConfiguration[T], dataSourcePlannerConfiguration plan.DataSourcePlannerConfiguration) error
type SchemaConfiguration ¶
type SchemaConfiguration struct {
// contains filtered or unexported fields
}
func NewSchemaConfiguration ¶
func NewSchemaConfiguration(upstreamSchema string, federationCfg *FederationConfiguration) (*SchemaConfiguration, error)
func (*SchemaConfiguration) FederationServiceSDL ¶
func (c *SchemaConfiguration) FederationServiceSDL() string
func (*SchemaConfiguration) IsFederationEnabled ¶
func (c *SchemaConfiguration) IsFederationEnabled() bool
type SingleTypeField ¶
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
func (*Source) LoadWithFiles ¶
func (s *Source) LoadWithFiles(ctx context.Context, input []byte, files []*httpclient.FileUpload, out *bytes.Buffer) (err error)
type SubscriptionConfiguration ¶
type SubscriptionConfiguration struct { URL string Header http.Header 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 WsSubProtocol string }
type SubscriptionSource ¶
type SubscriptionSource struct {
// contains filtered or unexported fields
}
func (*SubscriptionSource) AsyncStart ¶
func (s *SubscriptionSource) AsyncStart(ctx *resolve.Context, id uint64, input []byte, updater resolve.SubscriptionUpdater) error
func (*SubscriptionSource) AsyncStop ¶
func (s *SubscriptionSource) AsyncStop(id uint64)
AsyncStop stops the subscription with the given id. AsyncStop is only effective when netPoll is enabled because without netPoll we manage the lifecycle of the connection in the subscription client.
func (*SubscriptionSource) Start ¶
func (s *SubscriptionSource) Start(ctx *resolve.Context, input []byte, updater resolve.SubscriptionUpdater) error
Start the subscription. The updater is called on new events. Start needs to be called in a separate goroutine.
func (*SubscriptionSource) UniqueRequestID ¶
func (s *SubscriptionSource) UniqueRequestID(ctx *resolve.Context, input []byte, xxh *xxhash.Digest) (err error)
type UpgradeRequestError ¶
func (*UpgradeRequestError) Error ¶
func (u *UpgradeRequestError) Error() string