Help us shape the future of Go! Take the 2026 Go Developer Survey

generated

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownType  = errors.New("unknown type")
	ErrTypeNotFound = errors.New("type not found")
)

Functions

func NewExecutableSchema

func NewExecutableSchema(cfg Config) graphql.ExecutableSchema

NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.

Types

type ComplexityRoot

type ComplexityRoot struct {
	Entity struct {
		FindProductByUpc func(childComplexity int, upc string) int
	}

	Mutation struct {
		SetPrice func(childComplexity int, upc string, price int) int
	}

	Product struct {
		InStock func(childComplexity int) int
		Name    func(childComplexity int) int
		Price   func(childComplexity int) int
		Upc     func(childComplexity int) int
	}

	Query struct {
		TopProducts func(childComplexity int, first *int) int
		// contains filtered or unexported fields
	}

	Subscription struct {
		UpdateProductPrice func(childComplexity int, upc string) int
		UpdatedPrice       func(childComplexity int) int
	}
	// contains filtered or unexported fields
}

type Config

type Config struct {
	Schema     *ast.Schema
	Resolvers  ResolverRoot
	Directives DirectiveRoot
	Complexity ComplexityRoot
}

type DirectiveRoot

type DirectiveRoot struct {
}

type EntityRepresentation added in v1.6.0

type EntityRepresentation map[string]any

EntityRepresentation is the JSON representation of an entity sent by the Router used as the inputs for us to resolve.

We make it a map because we know the top level JSON is always an object.

type EntityResolver

type EntityResolver interface {
	FindProductByUpc(ctx context.Context, upc string) (*model.Product, error)
}

type EntityWithIndex added in v1.6.0

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

type MutationResolver

type MutationResolver interface {
	SetPrice(ctx context.Context, upc string, price int) (*model.Product, error)
}

type QueryResolver

type QueryResolver interface {
	TopProducts(ctx context.Context, first *int) ([]*model.Product, error)
}

type ResolverRoot

type ResolverRoot interface {
	Entity() EntityResolver
	Mutation() MutationResolver
	Query() QueryResolver
	Subscription() SubscriptionResolver
}

type SubscriptionResolver

type SubscriptionResolver interface {
	UpdatedPrice(ctx context.Context) (<-chan *model.Product, error)
	UpdateProductPrice(ctx context.Context, upc string) (<-chan *model.Product, error)
}

Jump to

Keyboard shortcuts

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