Documentation ¶
Overview ¶
Package interpreter contains the GraphQL interpreter for EliasDB.
Index ¶
- Constants
- Variables
- type DataSlice
- type GraphQLRuntimeProvider
- func (rtp *GraphQLRuntimeProvider) CheckWritePermission(path []string, node *parser.ASTNode) bool
- func (rtp *GraphQLRuntimeProvider) FetchNode(part string, key string, kind string) (data.Node, error)
- func (rtp *GraphQLRuntimeProvider) FetchNodePart(part string, key string, kind string, attrs []string) (data.Node, error)
- func (rtp *GraphQLRuntimeProvider) InitSubscription(rt *documentRuntime)
- func (rtp *GraphQLRuntimeProvider) Runtime(node *parser.ASTNode) parser.Runtime
- func (rtp *GraphQLRuntimeProvider) TraverseAST(root *parser.ASTNode, visitor func(*parser.ASTNode))
- type QueryType
- type RuntimeError
- type SubscriptionCallbackHandler
- type SystemRuleGraphQLSubscriptions
- func (r *SystemRuleGraphQLSubscriptions) AddHandler(handler *subscriptionHandler)
- func (r *SystemRuleGraphQLSubscriptions) Handle(gm *graph.Manager, trans graph.Trans, event int, ed ...interface{}) error
- func (r *SystemRuleGraphQLSubscriptions) Handles() []int
- func (r *SystemRuleGraphQLSubscriptions) Name() string
- func (r *SystemRuleGraphQLSubscriptions) RemoveHandler(handler *subscriptionHandler)
Constants ¶
const ( QueryTypeQuery QueryType = "query" QueryTypeMutation = "mutation" QueryTypeSubscription = "subscription" )
All known query types
const SystemRuleGraphQLSubscriptionsName = "system.graphqlsubscriptions"
SystemRuleGraphQLSubscriptionsName is the name of the graph manager rule which deals with subscriptions.
Variables ¶
var ( ErrInvalidConstruct = errors.New("Invalid construct") ErrAmbiguousDefinition = errors.New("Ambiguous definition") ErrMissingOperation = errors.New("Missing operation") ErrRuntimeError = errors.New("Runtime error") )
Runtime related error types
Functions ¶
This section is empty.
Types ¶
type DataSlice ¶
type DataSlice struct {
// contains filtered or unexported fields
}
DataSlice attaches the methods of sort.Interface to []map[string]interface{}, sorting in ascending or descending order by a given attribute.
type GraphQLRuntimeProvider ¶
type GraphQLRuntimeProvider struct { Name string // Name to identify the input QueryType QueryType // Query type (query, mutation, subscription) OperationName string // Name of operation to execute VariableValues map[string]interface{} // Values of variables ErrorKeys []string // List of error hashes (used for deduplication) Errors []*RuntimeError // List of errors ErrorPaths [][]string // List of error paths // contains filtered or unexported fields }
GraphQLRuntimeProvider defines the main interpreter datastructure and all functions for general evaluation.
func NewGraphQLRuntimeProvider ¶
func NewGraphQLRuntimeProvider(name string, part string, gm *graph.Manager, op string, vars map[string]interface{}, callbackHandler SubscriptionCallbackHandler, readOnly bool) *GraphQLRuntimeProvider
NewGraphQLRuntimeProvider creates a new GraphQLRuntimeProvider object.
func (*GraphQLRuntimeProvider) CheckWritePermission ¶
func (rtp *GraphQLRuntimeProvider) CheckWritePermission(path []string, node *parser.ASTNode) bool
CheckWritePermission checks if the current query is allowed to modify data. Returns true if data can be modified.
func (*GraphQLRuntimeProvider) FetchNode ¶
func (rtp *GraphQLRuntimeProvider) FetchNode(part string, key string, kind string) (data.Node, error)
FetchNode intercepts a FetchNode call to the graph.Manager in order to subscribe to node updates if necessary.
func (*GraphQLRuntimeProvider) FetchNodePart ¶
func (rtp *GraphQLRuntimeProvider) FetchNodePart(part string, key string, kind string, attrs []string) (data.Node, error)
FetchNodePart intercepts a FetchNodePart call to the graph.Manager in order to subscribe to node updates if necessary.
func (*GraphQLRuntimeProvider) InitSubscription ¶
func (rtp *GraphQLRuntimeProvider) InitSubscription(rt *documentRuntime)
InitSubscription ensures that the current graph manager has a rule for subscriptions to monitor data changes and forwards events to the subscription callback handler.
func (*GraphQLRuntimeProvider) Runtime ¶
func (rtp *GraphQLRuntimeProvider) Runtime(node *parser.ASTNode) parser.Runtime
Runtime returns a runtime component for a given ASTNode.
func (*GraphQLRuntimeProvider) TraverseAST ¶
func (rtp *GraphQLRuntimeProvider) TraverseAST(root *parser.ASTNode, visitor func(*parser.ASTNode))
TraverseAST traverses the AST starting with a given root and executes a given visitor function on each node. An accumulator is given to track state. A path is given to track selection sets.
type RuntimeError ¶
type RuntimeError struct { Source string // Name of the source which was given to the parser Type error // Error type (to be used for equal checks) Detail string // Details of this error Node *parser.ASTNode // AST Node where the error occurred Line int // Line of the error Pos int // Position of the error IsFatal bool // Is a fatal error which should stop the whole operation RuntimeProvider *GraphQLRuntimeProvider // Runtime provider which produced this error }
RuntimeError is a runtime related error
func (*RuntimeError) Error ¶
func (re *RuntimeError) Error() string
Error returns a human-readable string representation of this error.
type SubscriptionCallbackHandler ¶
type SubscriptionCallbackHandler interface { /* Publish is called for every event in the source stream of a subscription. This function should map the source stream event to a response stream event. */ Publish(map[string]interface{}, error) /* IsFinished should return true if this handler should no longer receive events. */ IsFinished() bool }
SubscriptionCallbackHandler receives source stream events for a subscription.
type SystemRuleGraphQLSubscriptions ¶
type SystemRuleGraphQLSubscriptions struct { ID string // Unique ID which identifies the rule // contains filtered or unexported fields }
SystemRuleGraphQLSubscriptions is a system rule to propagate state changes in the datastore to all relevant GraphQL subscriptions.
func (*SystemRuleGraphQLSubscriptions) AddHandler ¶
func (r *SystemRuleGraphQLSubscriptions) AddHandler(handler *subscriptionHandler)
AddHandler adds a new handler for rule events.
func (*SystemRuleGraphQLSubscriptions) Handle ¶
func (r *SystemRuleGraphQLSubscriptions) Handle(gm *graph.Manager, trans graph.Trans, event int, ed ...interface{}) error
Handle handles an event.
func (*SystemRuleGraphQLSubscriptions) Handles ¶
func (r *SystemRuleGraphQLSubscriptions) Handles() []int
Handles returns a list of events which are handled by this rule.
func (*SystemRuleGraphQLSubscriptions) Name ¶
func (r *SystemRuleGraphQLSubscriptions) Name() string
Name returns the name of the rule.
func (*SystemRuleGraphQLSubscriptions) RemoveHandler ¶
func (r *SystemRuleGraphQLSubscriptions) RemoveHandler(handler *subscriptionHandler)
RemoveHandler removes a handler from receiving further rule events.