Documentation ¶
Index ¶
- Constants
- func SetDefaultEnvironment(e Environment)
- type AuthorizeConfig
- type BlockingSubscriptionExtension
- func (b *BlockingSubscriptionExtension) GetResult(ctx context.Context) interface{}
- func (b *BlockingSubscriptionExtension) Name() string
- func (r BlockingSubscriptionExtension) ParseDidStart(ctx context.Context) (context.Context, graphql.ParseFinishFunc)
- func (r BlockingSubscriptionExtension) ValidationDidStart(ctx context.Context) (context.Context, graphql.ValidationFinishFunc)
- type BlockingSubscriptionHandler
- type BlockingSubscriptionPayload
- type Config
- type Context
- type Dispatch
- func (d Dispatch) Authorize(auth AuthorizeConfig) func(params *graphql.Params) (bool, error)
- func (d Dispatch) FieldResolve(rs ResolverConfig) func(params graphql.ResolveParams) (interface{}, error)
- func (d Dispatch) InterfaceResolveType(i InterfaceConfig) func(params graphql.ResolveTypeParams) *graphql.Object
- func (d Dispatch) ScalarFunctions(s ScalarConfig) parser.ScalarFunctions
- func (d Dispatch) UnionResolveType(u UnionConfig) func(params graphql.ResolveTypeParams) *graphql.Object
- type Environment
- type ExternalSubscriptionExtension
- func (e *ExternalSubscriptionExtension) GetResult(ctx context.Context) interface{}
- func (e *ExternalSubscriptionExtension) Name() string
- func (r ExternalSubscriptionExtension) ParseDidStart(ctx context.Context) (context.Context, graphql.ParseFinishFunc)
- func (r ExternalSubscriptionExtension) ValidationDidStart(ctx context.Context) (context.Context, graphql.ValidationFinishFunc)
- type ExternalSubscriptionHandler
- type InterfaceConfig
- type ResolverConfig
- type Router
- type ScalarConfig
- type SecretsConfig
- type SubscribeContext
- type SubscribeExtension
- func (s *SubscribeExtension) Exclude(f string)
- func (s *SubscribeExtension) ExecutionDidStart(ctx context.Context) (context.Context, graphql.ExecutionFinishFunc)
- func (r SubscribeExtension) GetResult(ctx context.Context) interface{}
- func (s *SubscribeExtension) HasResult(ctx context.Context) bool
- func (s *SubscribeExtension) Include(f string)
- func (s *SubscribeExtension) Init(ctx context.Context, p *graphql.Params) context.Context
- func (r SubscribeExtension) ParseDidStart(ctx context.Context) (context.Context, graphql.ParseFinishFunc)
- func (s *SubscribeExtension) ResolveFieldDidStart(ctx context.Context, info *graphql.ResolveInfo) (context.Context, graphql.ResolveFieldFinishFunc)
- func (r SubscribeExtension) ValidationDidStart(ctx context.Context) (context.Context, graphql.ValidationFinishFunc)
- type SubscriptionConfig
- type SubscriptionKind
- type TypeMap
- type UnionConfig
- type WebhookConfig
Constants ¶
const ContextKey routerContext = 0
ContextKey returns shared router context from context associated with request
const ProtocolKey protocolKey = 0
ProtocolKey used to pass extra data from protocol used for comunication
const RawSubscriptionKey rawSubscriptionKey = 0
RawSubscriptionKey used to pass instruction about how a subscription should be handled.
const SchemaEnv = "STUCCO_SCHEMA"
SchemaEnv is a name of environment variable that will be checked for schema if one is not provided
const SubscriptionPayloadKey subscriptionContextKey = 0
SubscriptionPayloadKey payload value for subscription in context
Variables ¶
This section is empty.
Functions ¶
func SetDefaultEnvironment ¶
func SetDefaultEnvironment(e Environment)
SetDefaultEnvironment for router
Types ¶
type AuthorizeConfig ¶
type AuthorizeConfig struct { Environment *Environment `json:"environment,omitempty"` Authorize types.Function `json:"authorize"` }
AuthorizeConfig is an authorize function config
type BlockingSubscriptionExtension ¶
type BlockingSubscriptionExtension struct {
SubscribeExtension
}
BlockingSubscriptionExtension is a blocking subscription extension
func (*BlockingSubscriptionExtension) GetResult ¶
func (b *BlockingSubscriptionExtension) GetResult(ctx context.Context) interface{}
GetResult implements graphql.Extension
func (*BlockingSubscriptionExtension) Name ¶
func (b *BlockingSubscriptionExtension) Name() string
Name implements graphql.Extension
func (BlockingSubscriptionExtension) ParseDidStart ¶
func (BlockingSubscriptionExtension) ValidationDidStart ¶
type BlockingSubscriptionHandler ¶
type BlockingSubscriptionHandler interface {
SubscriptionListen(driver.SubscriptionListenInput) (*driver.SubscriptionListenOutput, error)
}
BlockingSubscriptionHandler can be implemented by field returned from root object on API to prepare connection data If SubscriptionConnection returns an error, that error will be returned. If it returns nil error and nil output value, then further execution is attempted. Otherwise value returned by handler is used to prepare extension output.
type BlockingSubscriptionPayload ¶
type BlockingSubscriptionPayload struct { Context SubscribeContext Reader driver.SubscriptionListenReader }
BlockingSubscriptionPayload returns data for blocking subscriptions to be handled by blocking protocol
type Config ¶
type Config struct { Environment Environment `json:"environment"` // Environment is a default config of a router Interfaces map[string]InterfaceConfig `json:"interfaces"` // Interfaces is a map of FaaS function configs used in determining concrete type of an interface Resolvers map[string]ResolverConfig `json:"resolvers"` // Resolvers is a map of FaaS function configs used in resolution Scalars map[string]ScalarConfig `json:"scalars"` // Scalars is a map of FaaS function configs used in parsing and serializing custom scalars Schema string `json:"schema"` // String with GraphQL schema or an URL to the schema Unions map[string]UnionConfig `json:"unions"` // Unions is a map of FaaS function configs used in determining concrete type of an union Secrets SecretsConfig `json:"secrets"` // Secrets is a map of references to secrets Subscriptions SubscriptionConfig `json:"subscriptions"` // Configure subscription behaviour SubscriptionConfigs map[string]SubscriptionConfig `json:"subscriptionConfigs"` // Configure subscription behaviour per field MaxDepth int `json:"maxDepth,omitempty"` Authorize *AuthorizeConfig `json:"authorize,omitempty"` // Authorize configures optional authorization function before any resolver is ran RequestTimeout int64 `json:"requestTimeout,omitempty"` }
Config is a router configuration mapping defined endpoints with thier runtime config
func (*Config) AddInterface ¶
AddInterface creates a new interface resolve type mapping in config
func (*Config) AddResolver ¶
AddResolver creates a new resolver mapping in config
type Dispatch ¶
type Dispatch struct { driver.Driver TypeMap TypeMap MaxDepth int // Maximum depth for GraphQL recursion }
Dispatch executes a resolution through a driver
func (Dispatch) Authorize ¶
Authorize creates a function that calls implementation of field resolution through driver
func (Dispatch) FieldResolve ¶
func (d Dispatch) FieldResolve(rs ResolverConfig) func(params graphql.ResolveParams) (interface{}, error)
FieldResolve creates a function that calls implementation of field resolution through driver
func (Dispatch) InterfaceResolveType ¶
func (d Dispatch) InterfaceResolveType(i InterfaceConfig) func(params graphql.ResolveTypeParams) *graphql.Object
InterfaceResolveType creates a function that calls implementation of interface type resolution
func (Dispatch) ScalarFunctions ¶
func (d Dispatch) ScalarFunctions(s ScalarConfig) parser.ScalarFunctions
ScalarFunctions creates parse and serialize scalar functions that call implementation of scalar and parse through driver
func (Dispatch) UnionResolveType ¶
func (d Dispatch) UnionResolveType(u UnionConfig) func(params graphql.ResolveTypeParams) *graphql.Object
UnionResolveType creates a function that calls union resolution using driver
type Environment ¶
type Environment struct { Provider string `json:"provider,omitempty"` Runtime string `json:"runtime,omitempty"` }
Environment runtime environment for a function
func DefaultEnvironment ¶
func DefaultEnvironment() Environment
DefaultEnvironment return default environment
func (*Environment) Merge ¶
func (e *Environment) Merge(src Environment)
Merge environments, original values have higher priority
type ExternalSubscriptionExtension ¶
type ExternalSubscriptionExtension struct {
SubscribeExtension
}
ExternalSubscriptionExtension is a blocking subscription extension
func (*ExternalSubscriptionExtension) GetResult ¶
func (e *ExternalSubscriptionExtension) GetResult(ctx context.Context) interface{}
GetResult implements graphql.Extension
func (*ExternalSubscriptionExtension) Name ¶
func (e *ExternalSubscriptionExtension) Name() string
Name implements graphql.Extension
func (ExternalSubscriptionExtension) ParseDidStart ¶
func (ExternalSubscriptionExtension) ValidationDidStart ¶
type ExternalSubscriptionHandler ¶
type ExternalSubscriptionHandler interface {
SubscriptionConnection(driver.SubscriptionConnectionInput) (*driver.SubscriptionConnectionOutput, error)
}
ExternalSubscriptionHandler can be implemented by root object on API to prepare connection data If SubscriptionConnection returns an error, that error will be returned. If it returns nil error and nil output value, then further execution is attempted. Otherwise value returned by handler is used to prepare extension output.
type InterfaceConfig ¶
type InterfaceConfig struct { Environment *Environment `json:"environment,omitempty"` ResolveType types.Function `json:"resolveType"` Webhooks map[string]WebhookConfig `json:"webhooks,omitempty"` }
InterfaceConfig defines function configuration for interface type resolution
type ResolverConfig ¶
type ResolverConfig struct { Environment *Environment `json:"environment,omitempty"` Resolve types.Function `json:"resolve"` Skip bool `json:"skip"` Webhook *WebhookConfig `json:"webhook,omitempty"` }
ResolverConfig defines function configuration for field resolver
type Router ¶
type Router struct { Interfaces map[string]InterfaceConfig // Interfaces is a map of FaaS function configs used in determining concrete type of an interface Resolvers map[string]ResolverConfig // Resolvers is a map of FaaS function configs used in resolution Scalars map[string]ScalarConfig // Scalars is a map of FaaS function configs used in parsing and serializing custom scalars Unions map[string]UnionConfig // Unions is a map of FaaS function configs used in determining concrete type of an union Schema graphql.Schema // Parsed schema Secrets SecretsConfig // Secrets is a map of secret references Subscriptions SubscriptionConfig // global subscription config SubscriptionConfigs map[string]SubscriptionConfig // subscription config per subscription field MaxDepth int // allow limiting max depth of GraphQL recursion RequestTimeout *time.Duration }
Router dispatches defined functions to a driver that handles them
type ScalarConfig ¶
type ScalarConfig struct { Environment *Environment `json:"environment,omitempty"` Parse types.Function `json:"parse"` Serialize types.Function `json:"serialize"` }
ScalarConfig defines parse and serialize function configurations for scalar
type SecretsConfig ¶
SecretsConfig defines a secret configuration for router
type SubscribeContext ¶
type SubscribeContext struct { Context context.Context Query string `json:"query,omitempty"` VariableValues map[string]interface{} `json:"variableValues,omitempty"` OperationName string `json:"operationName,omitempty"` OperationDefinition *types.OperationDefinition `json:"operationDefinition,omitempty"` IsSubscription bool `json:"-"` Reader driver.SubscriptionListenReader `json:"-"` // contains filtered or unexported fields }
SubscribeContext contains information about subscription execution
type SubscribeExtension ¶
type SubscribeExtension struct {
// contains filtered or unexported fields
}
SubscribeExtension implements custom behaviour for extension types It basically passes through most of the parsing and validation process but short circuts the execution returning a custom result that should further be processed.
func (*SubscribeExtension) Exclude ¶
func (s *SubscribeExtension) Exclude(f string)
Exclude field from handling
func (*SubscribeExtension) ExecutionDidStart ¶
func (s *SubscribeExtension) ExecutionDidStart(ctx context.Context) (context.Context, graphql.ExecutionFinishFunc)
ExecutionDidStart implements graphql.Extension
func (*SubscribeExtension) HasResult ¶
func (s *SubscribeExtension) HasResult(ctx context.Context) bool
HasResult implements graphql.Extension
func (*SubscribeExtension) Include ¶
func (s *SubscribeExtension) Include(f string)
Include field in handling
func (SubscribeExtension) ParseDidStart ¶
func (*SubscribeExtension) ResolveFieldDidStart ¶
func (s *SubscribeExtension) ResolveFieldDidStart(ctx context.Context, info *graphql.ResolveInfo) (context.Context, graphql.ResolveFieldFinishFunc)
ResolveFieldDidStart implements graphql.Extension Hijacks the resolution of root subscription fields
func (SubscribeExtension) ValidationDidStart ¶
type SubscriptionConfig ¶
type SubscriptionConfig struct { Environment *Environment `json:"environment,omitempty"` Kind SubscriptionKind `json:"kind,omitempty"` CreateConnection types.Function `json:"createConnection,omitempty"` Listen types.Function `json:"listen,omitempty"` }
SubscriptionConfig configures subscription handling for stucco
type SubscriptionKind ¶
type SubscriptionKind uint8
SubscriptionKind defines allowed types of subscription
const ( // DefaultSubscription defaults to internal DefaultSubscription SubscriptionKind = iota // BlockingSubscription subscription keeps alive subscription connection until client disconnects and streams BlockingSubscription // ExternalSubscription subscription returns a value from extension with connection payload to external service ExternalSubscription // RedirectSubscription returns 302 response with a redirect address being a user generated address RedirectSubscription )
func (*SubscriptionKind) UnmarshalJSON ¶
func (s *SubscriptionKind) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler
type UnionConfig ¶
type UnionConfig struct { Environment *Environment `json:"environment,omitempty"` ResolveType types.Function `json:"resolveType"` }
UnionConfig defines function configuration for union type resolution