fedruntime

package
v1.17.92 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnknownType is returned when an unknown entity type is encountered
	ErrUnknownType = errors.New("unknown type")
	// ErrTypeNotFound is returned when an entity type cannot be resolved
	ErrTypeNotFound = errors.New("type not found")
)

Functions

func ChainDirectives

func ChainDirectives(
	ctx context.Context, base ResolverFunc, directives []DirectiveFunc,
) (any, error)

ChainDirectives applies a chain of directives to a base resolver function. Directives are applied in reverse order, with each directive wrapping the next one.

func ValidateEntityKeys

func ValidateEntityKeys(
	entityName string,
	rep map[string]any,
	resolverChecks []ResolverKeyCheck,
) (string, error)

ValidateEntityKeys determines which resolver to use for an entity representation. It checks that all required key fields exist and are not all null. Returns the resolver name if valid, or an error if no resolver matches.

func WrapEntityResolver

func WrapEntityResolver[T any](
	ctx context.Context,
	typedResolver func(context.Context) (T, error),
	directives []DirectiveFunc,
) (T, error)

WrapEntityResolver wraps an entity resolver with directive middleware. If no directives are provided, the resolver is called directly. Otherwise, directives are applied and the result is type-checked.

Types

type DirectiveFunc

type DirectiveFunc func(context.Context, ResolverFunc) (any, error)

DirectiveFunc wraps a resolver with directive middleware logic. It receives the context and the next resolver in the chain, and returns the result.

type Entity

type Entity interface {
	IsEntity()
}

Everything with a @key implements this

type KeyFieldCheck

type KeyFieldCheck struct {
	// FieldPath is the path to the field (e.g., ["id"] or ["user", "id"] for nested fields)
	FieldPath []string
}

KeyFieldCheck represents a key field validation check.

type Link any

Used for the Link directive

type ResolverFunc

type ResolverFunc func(context.Context) (any, error)

ResolverFunc is a function that resolves a value in the context of federation entity resolution. It matches the signature used throughout the GraphQL execution pipeline.

type ResolverKeyCheck

type ResolverKeyCheck struct {
	// ResolverName is the name of the resolver function
	ResolverName string
	// KeyFields are the required key fields for this resolver
	KeyFields []KeyFieldCheck
}

ResolverKeyCheck represents the key requirements for a resolver.

type Service

type Service struct {
	SDL string `json:"sdl"`
}

Service is the service object that the generated.go file will return for the _service query

Jump to

Keyboard shortcuts

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