Documentation
¶
Index ¶
- Constants
- type Entity
- type EntityResolver
- type Federation
- func (f *Federation) GenerateCode(data *codegen.Data) error
- func (f *Federation) InjectSourcesEarly() ([]*ast.Source, error)
- func (f *Federation) InjectSourcesLate(schema *ast.Schema) ([]*ast.Source, error)
- func (f *Federation) MutateConfig(cfg *config.Config) error
- func (f *Federation) Name() string
- type KeyField
- type PackageOptions
- type Requires
Constants ¶
const DirArgFields = "fields"
The fields arguments must be provided to both key and requires directives.
const DirArgType = "type"
Tells the code generator what type the directive is referencing
const DirNameEntityReference = "entityReference"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entity ¶
type Entity struct {
Name string // The same name as the type declaration
Def *ast.Definition
Resolvers []*EntityResolver
Requires []*Requires
Multi bool
Type types.Type
// ImplDirectives are the resolved non-federation OBJECT-level directives
// with full type information, populated in GenerateCode for use in the
// federation template to wrap entity resolver calls.
ImplDirectives []*codegen.Directive
}
Entity represents a federated type that was declared in the GQL schema.
func (Entity) GetTypeInfo ¶ added in v0.17.45
GetTypeInfo - get the imported package & type name combo. package.TypeName
func (*Entity) HasObjectDirectives ¶ added in v0.17.87
HasObjectDirectives reports whether this entity's type definition carries any non-federation user-defined directives that should be applied at runtime when the entity is resolved through the _entities query.
func (*Entity) NonFederationDirectives ¶ added in v0.17.87
func (e *Entity) NonFederationDirectives() ast.DirectiveList
NonFederationDirectives returns the AST directives applied to this entity, excluding federation-internal and gqlgen-internal directives.
type EntityResolver ¶ added in v0.15.0
type EntityResolver struct {
ResolverName string // The resolver name, such as FindUserByID
KeyFields []*KeyField // The fields declared in @key.
InputType types.Type // The Go generated input type for multi entity resolvers
InputTypeName string
ReturnType types.Type // The Go generated return type for the entity
ReturnTypeName string
}
func (*EntityResolver) IsPointerReturnType ¶ added in v0.17.87
func (e *EntityResolver) IsPointerReturnType() bool
IsPointerReturnType returns true if the resolver's return type is a pointer
func (*EntityResolver) LookupInputType ¶ added in v0.17.28
func (e *EntityResolver) LookupInputType() string
func (*EntityResolver) LookupReturnType ¶ added in v0.17.87
func (e *EntityResolver) LookupReturnType() string
type Federation ¶ added in v0.17.54
type Federation struct {
Entities []*Entity
RequiresEntities map[string]*Entity
PackageOptions PackageOptions
// contains filtered or unexported fields
}
func New ¶
func New(version int, cfg *config.Config) (*Federation, error)
New returns a federation plugin that injects federated directives and types into the schema
func (*Federation) GenerateCode ¶ added in v0.17.54
func (f *Federation) GenerateCode(data *codegen.Data) error
func (*Federation) InjectSourcesEarly ¶ added in v0.17.54
func (f *Federation) InjectSourcesEarly() ([]*ast.Source, error)
func (*Federation) InjectSourcesLate ¶ added in v0.17.54
InjectSourcesLate creates a GraphQL Entity type with all the fields that had the @key directive
func (*Federation) MutateConfig ¶ added in v0.17.54
func (f *Federation) MutateConfig(cfg *config.Config) error
MutateConfig mutates the configuration
func (*Federation) Name ¶ added in v0.17.54
func (f *Federation) Name() string
Name returns the plugin name
type KeyField ¶
type KeyField struct {
Definition *ast.FieldDefinition
Field fieldset.Field // len > 1 for nested fields
Type *config.TypeReference // The Go representation of that field type
}
type PackageOptions ¶ added in v0.17.54
type PackageOptions struct {
// ExplicitRequires will generate a function in the execution context
// to populate fields using the @required directive into the entity.
//
// You can only set one of ExplicitRequires or ComputedRequires to true.
ExplicitRequires bool
// ComputedRequires generates resolver functions to compute values for
// fields using the @required directive.
ComputedRequires bool
// EntityResolverMulti is default engine for entityResolver generation.
// This can be overriding by @entityResolver(multi: Boolean) directive.
// false by default.
EntityResolverMulti bool
}