graphql_datasource

package
v0.0.0-...-5e166c9 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: MIT Imports: 32 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ProtocolGraphQLTWS = "graphql-transport-ws"
)

websocket sub-protocol: https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.md

View Source
const (
	ProtocolGraphQLWS = "graphql-ws"
)

websocket sub-protocol: https://github.com/apollographql/subscriptions-transport-ws/blob/master/PROTOCOL.md

Variables

This section is empty.

Functions

func ConfigJson

func ConfigJson(config Configuration) json.RawMessage

Types

type Batch

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

func (*Batch) Demultiplex

func (b *Batch) Demultiplex(responseBufPair *resolve.BufPair, bufPairs []*resolve.BufPair) (err error)

func (*Batch) Input

func (b *Batch) Input() *fastbuffer.FastBuffer

type BatchFactory

type BatchFactory struct{}

func NewBatchFactory

func NewBatchFactory() *BatchFactory

func (*BatchFactory) CreateBatch

func (b *BatchFactory) CreateBatch(inputs [][]byte) (resolve.DataSourceBatch, error)

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 {
	BatchFactory               resolve.DataSourceBatchFactory
	HTTPClient                 *http.Client
	StreamingClient            *http.Client
	OnWsConnectionInitCallback *OnWsConnectionInitCallback
	SubscriptionClient         *SubscriptionClient
}

func (*Factory) Planner

func (f *Factory) Planner(ctx context.Context) plan.DataSourcePlanner

type FederationConfiguration

type FederationConfiguration struct {
	Enabled    bool
	ServiceSDL string
}

type FetchConfiguration

type FetchConfiguration struct {
	URL    string
	Method string
	Header http.Header
}

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 context.Context, options GraphQLSubscriptionOptions, next chan<- []byte) 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"`
	Body          GraphQLBody `json:"body"`
	Header        http.Header `json:"header"`
	UseSSE        bool        `json:"use_sse"`
	SSEMethodPost bool        `json:"sse_method_post"`
}

type OnWsConnectionInitCallback

type OnWsConnectionInitCallback func(ctx context.Context, url string, header http.Header) (json.RawMessage, error)

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 WithReadTimeout(timeout time.Duration) Options

func WithWSSubProtocol

func WithWSSubProtocol(protocol string) Options

type Planner

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

func (*Planner) ConfigureFetch

func (p *Planner) ConfigureFetch() plan.FetchConfiguration

func (*Planner) ConfigureSubscription

func (p *Planner) ConfigureSubscription() plan.SubscriptionConfiguration

func (*Planner) DataSourcePlanningBehavior

func (p *Planner) DataSourcePlanningBehavior() plan.DataSourcePlanningBehavior

func (*Planner) DownstreamResponseFieldAlias

func (p *Planner) DownstreamResponseFieldAlias(downstreamFieldRef int) (alias string, exists bool)

func (*Planner) EnterArgument

func (p *Planner) EnterArgument(_ int)

func (*Planner) EnterDirective

func (p *Planner) EnterDirective(ref int)

func (*Planner) EnterDocument

func (p *Planner) EnterDocument(_, _ *ast.Document)

func (*Planner) EnterField

func (p *Planner) EnterField(ref int)

func (*Planner) EnterInlineFragment

func (p *Planner) EnterInlineFragment(ref int)

func (*Planner) EnterOperationDefinition

func (p *Planner) EnterOperationDefinition(ref int)

func (*Planner) EnterSelectionSet

func (p *Planner) EnterSelectionSet(ref int)

func (*Planner) EnterVariableDefinition

func (p *Planner) EnterVariableDefinition(ref int)

func (*Planner) LeaveDocument

func (p *Planner) LeaveDocument(_, _ *ast.Document)

func (*Planner) LeaveField

func (p *Planner) LeaveField(ref int)

func (*Planner) LeaveInlineFragment

func (p *Planner) LeaveInlineFragment(_ int)

func (*Planner) LeaveOperationDefinition

func (p *Planner) LeaveOperationDefinition(_ int)

func (*Planner) LeaveSelectionSet

func (p *Planner) LeaveSelectionSet(_ int)

func (*Planner) LeaveVariableDefinition

func (p *Planner) LeaveVariableDefinition(_ int)

func (*Planner) Register

func (p *Planner) Register(visitor *plan.Visitor, configuration plan.DataSourceConfiguration, isNested bool) error

type SingleTypeField

type SingleTypeField struct {
	TypeName  string
	FieldName string
}

type Source

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

func (*Source) Load

func (s *Source) Load(ctx context.Context, input []byte, writer io.Writer) (err error)

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 NewGraphQLSubscriptionClient

func NewGraphQLSubscriptionClient(httpClient, streamingClient *http.Client, engineCtx context.Context, options ...Options) *SubscriptionClient

func (*SubscriptionClient) Subscribe

func (c *SubscriptionClient) Subscribe(reqCtx context.Context, options GraphQLSubscriptionOptions, next chan<- []byte) 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

type SubscriptionConfiguration

type SubscriptionConfiguration struct {
	URL           string
	UseSSE        bool
	SSEMethodPost bool
}

type SubscriptionSource

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

func (*SubscriptionSource) Start

func (s *SubscriptionSource) Start(ctx context.Context, input []byte, next chan<- []byte) error

Jump to

Keyboard shortcuts

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