package federation
import "github.com/99designs/gqlgen/plugin/federation"
Index ¶
- Constants
- type Entity
- type EntityResolver
- type Federation
- func New(version int, cfg *config.Config) (*Federation, error)
- 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"
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 }
Entity represents a federated type that was declared in the GQL schema.
func (Entity) GetTypeInfo ¶
GetTypeInfo - get the imported package & type name combo. package.TypeName
type EntityResolver ¶
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) LookupInputType ¶
func (e *EntityResolver) LookupInputType() string
type Federation ¶
type Federation struct { Entities []*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 ¶
func (f *Federation) GenerateCode(data *codegen.Data) error
func (*Federation) InjectSourcesEarly ¶
func (f *Federation) InjectSourcesEarly() ([]*ast.Source, error)
func (*Federation) InjectSourcesLate ¶
InjectSourceLate creates a GraphQL Entity type with all the fields that had the @key directive
func (*Federation) MutateConfig ¶
func (f *Federation) MutateConfig(cfg *config.Config) error
MutateConfig mutates the configuration
func (*Federation) Name ¶
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 ¶
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 }
type Requires ¶
type Requires struct { Name string // the name of the field Field fieldset.Field // source Field, len > 1 for nested fields Type *config.TypeReference // The Go representation of that field type }
Requires represents an @requires clause
Source Files ¶
constants.go entity.go federation.go
Directories ¶
Path | Synopsis |
---|---|
plugin/federation/fedruntime | |
plugin/federation/fieldset | |
plugin/federation/test_data | |
plugin/federation/test_data/model | |
plugin/federation/test_data/model2 |
- Version
- v0.17.73 (latest)
- Published
- May 2, 2025
- Platform
- linux/amd64
- Imports
- 12 packages
- Last checked
- 6 days ago –
Tools for package owners.