Documentation ¶
Overview ¶
Package compiler provides utilities for working with GraphQL documents.
Index ¶
- Variables
- func CheckTypes(docs IR, checkers ...TypeChecker) (errs []error)
- func FromIR(ir IR) []*ast.Document
- func Lookup(name string, ir IR) (*ast.Document, []*ast.TypeDecl)
- func MergeExtensions(types map[string][]*ast.TypeDecl) map[string][]*ast.TypeDecl
- func RegisterTypes(decls ...*ast.TypeDecl)
- func TestTypeChecker(t tester, v TypeChecker)
- type IR
- type ImportError
- type TypeChecker
- type TypeCheckerFn
- type TypeError
Constants ¶
This section is empty.
Variables ¶
var ImportValidator = TypeCheckerFn(validateImports)
ImportValidator validates that all types are correctly imported.
var Types []*ast.TypeDecl
Types contains the builtin types provided by the compiler and any custom types given to RegisterTypes.
Functions ¶
func CheckTypes ¶
func CheckTypes(docs IR, checkers ...TypeChecker) (errs []error)
CheckTypes is a helper function for running a suite of type checking on several GraphQL Documents. Any types given to RegisterTypes will included as their very own document.
func FromIR ¶
FromIR converts the compiler intermediate representation back to a simple slice of GraphQL Documents.
func MergeExtensions ¶
MergeExtensions merges type extensions with their original declaration.
func RegisterTypes ¶
RegisterTypes registers pre-defined types with the compiler.
func TestTypeChecker ¶
func TestTypeChecker(t tester, v TypeChecker)
TestTypeChecker implements a few tests for custom type checkers. It is mainly focused around ensuring validation across imports.
Types ¶
type IR ¶
IR is a representation used by the compiler APIs.
func ReduceImports ¶
ReduceImports reduces a set of Documents by including imported type defs into the Documents that they're imported into.
To import a Document the @import directive is used: directive @import(paths: [String]) on DOCUMENT
type ImportError ¶
ImportError represents an error with the imports in a GraphQL Document
func (*ImportError) Error ¶
func (e *ImportError) Error() string
type TypeChecker ¶
type TypeChecker interface { // Check performs type checking on the types in the IR. Check(ir IR) []error }
TypeChecker represents type checking functionality for a GraphQL Document.
type TypeCheckerFn ¶
TypeCheckerFn represents a single function behaving as a TypeChecker.
func (TypeCheckerFn) Check ¶
func (f TypeCheckerFn) Check(ir IR) []error
Check calls the TypeCheckerFn given the GraphQL Document.