Documentation
¶
Index ¶
- Variables
- func ChainDirectives(ctx context.Context, base ResolverFunc, directives []DirectiveFunc) (any, error)
- func ValidateEntityKeys(entityName string, rep map[string]any, resolverChecks []ResolverKeyCheck) (string, error)
- func WrapEntityResolver[T any](ctx context.Context, typedResolver func(context.Context) (T, error), ...) (T, error)
- type DirectiveFunc
- type Entity
- type KeyFieldCheck
- type Link
- type ResolverFunc
- type ResolverKeyCheck
- type Service
Constants ¶
This section is empty.
Variables ¶
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 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 ResolverFunc ¶
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.