analysis

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ASTLookup

type ASTLookup interface {
	LookupType(ast.Type) ast.TypeDefinition
}

ASTLookup must lookup types in the original schema.

type Model

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

Model defines the linkage between a GraphQL schema and a codebase. Schema types are bound to Go types, for example:

  • Object type bound to Go struct or interface type
  • Array type bound to Go struct or channel type
  • Any type bound to Go channel(s) indicating mutable real-time value

This representation yields Resolver implementations that emit Go code to resolve at runtime.

func BuildModel

func BuildModel(
	rootSchema *ast.ObjectDefinition,
	astLookup ASTLookup,
	rootResolverType gtypes.Type,
) (*Model, error)

BuildModel computes the execution model from a schema and code sample.

func (*Model) GenerateResolverFile

func (m *Model) GenerateResolverFile() (*gast.File, error)

GenerateResolverFile generates the Go resolver file.

func (*Model) GetAllResolvers

func (m *Model) GetAllResolvers() []Resolver

GetAllResolvers returns the list of all generated resolvers.

func (*Model) GetImportPaths

func (m *Model) GetImportPaths() []string

GetImportPaths returns the import path list.

func (*Model) GetRootResolver

func (m *Model) GetRootResolver() Resolver

GetRootResolver returns the root resolver reference.

type Resolver

type Resolver interface {
	// GetName returns the resolver name.
	// This is typically the function name.
	GetName() string
	// GenerateGoASTDecls generates Go declarations to fulfill the resolver.
	GenerateGoASTDecls() ([]gast.Decl, error)
	// GenerateGoASTRef generates the Go statements to call the resolver.
	GenerateGoASTRef() ([]gast.Stmt, error)
}

Resolver implements resolution of a piece of the schema with Go code.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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