development

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2022 License: Apache-2.0 Imports: 31 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompileSchema

func CompileSchema(schema string) ([]*core.NamespaceDefinition, *v0.DeveloperError, error)

CompileSchema compiles a schema into its namespace definition(s), returning a developer error if the schema could not be compiled. The non-developer error is returned only if an internal errors occurred.

func DistinguishGraphError

func DistinguishGraphError(devContext *DevContext, dispatchError error, source v0.DeveloperError_Source, line uint32, column uint32, context string) (*v0.DeveloperError, error)

DistinguishGraphError turns an error from a dispatch call into either a user-facing DeveloperError or an internal error, based on the error raised by the dispatcher.

func GenerateValidation

func GenerateValidation(membershipSet *membership.Set) (string, error)

GenerateValidation generates the validation block based on a membership set.

func NewDevContext

func NewDevContext(ctx context.Context, developerRequestContext *v0.RequestContext) (*DevContext, *DeveloperErrors, error)

NewDevContext creates a new DevContext from the specified request context, parsing and populating the datastore as needed.

func ParseAssertionsYAML

func ParseAssertionsYAML(assertionsYaml string) (*blocks.Assertions, *v0.DeveloperError)

ParseAssertionsYAML parses the YAML form of an assertions block.

func ParseExpectedRelationsYAML

func ParseExpectedRelationsYAML(expectedRelationsYaml string) (*blocks.ParsedExpectedRelations, *v0.DeveloperError)

ParseExpectedRelationsYAML parses the YAML form of an expected relations block.

func RunCheck

RunCheck performs a check against the data in the development context.

Note that it is up to the caller to call DistinguishGraphError on the error if they want to distinguish between user errors and internal errors.

Types

type DevContext

type DevContext struct {
	Ctx              context.Context
	Datastore        datastore.Datastore
	Revision         decimal.Decimal
	Namespaces       []*v0.NamespaceDefinition
	Dispatcher       dispatch.Dispatcher
	NamespaceManager namespace.Manager
}

DevContext holds the various helper types for running the developer calls.

func (*DevContext) Dispose

func (dc *DevContext) Dispose()

Dispose disposes of the DevContext and its underlying datastore.

type DeveloperErrors

type DeveloperErrors struct {
	// InputErrors hold any errors found in the input to the development tooling,
	// e.g. invalid schema, invalid relationship, etc.
	InputErrors []*v0.DeveloperError

	// ValidationErrors holds any validation errors/inconsistencies found,
	// e.g. assertion failure, incorrect expection relations, etc.
	ValidationErrors []*v0.DeveloperError
}

DeveloperErrors is a struct holding the various kinds of errors for a DevContext operation.

func RunAllAssertions

func RunAllAssertions(devContext *DevContext, assertions *blocks.Assertions) (*DeveloperErrors, error)

RunAllAssertions runs all assertions found in the given assertions block against the developer context, returning whether any errors occurred.

func RunValidation

func RunValidation(devContext *DevContext, validation *blocks.ParsedExpectedRelations) (*membership.Set, *DeveloperErrors, error)

RunValidation runs the parsed validation block against the data in the dev context.

Jump to

Keyboard shortcuts

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