Documentation
¶
Overview ¶
Package config loads and validates .defederator.yml configuration files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Schema is the path to the Federation v2 supergraph SDL.
// It is used both as the routing table and as the GraphQL schema for type generation.
Schema string `yaml:"schema"`
// Query lists glob patterns or explicit paths to .graphql operation files.
Query []string `yaml:"query"`
// Client configures the generated client Go file.
Client PackageConfig `yaml:"client"`
// Model optionally generates model types into a separate file.
Model PackageConfig `yaml:"model,omitempty"`
// SubgraphURLs overrides subgraph URLs at runtime.
// Keys are join__Graph enum values (e.g. "PRODUCTS").
SubgraphURLs map[string]string `yaml:"subgraph_urls,omitempty"`
// Bindings maps GraphQL scalar names to Go types. Equivalent to genqlient's
// bindings: section.
Bindings map[string]TypeBinding `yaml:"bindings,omitempty"`
// Generate controls optional generation behaviours.
Generate *GenerateConfig `yaml:"generate,omitempty"`
// URLMode controls how subgraph URLs appear in generated plan specs.
// "baked" (default): URLs from the supergraph SDL are embedded in the
// plan spec constants at generation time. NewClient takes only an *http.Client.
// "enum": plan specs use subgraph enum names; URLs are provided at runtime.
// NewClient takes an additional subgraphURLs map[string]string parameter.
// Use "enum" when the supergraph SDL contains placeholder URLs (e.g. "unused").
URLMode string `yaml:"url_mode,omitempty"`
// Dir is the base directory for resolving relative paths (not serialised).
Dir string `yaml:"-"`
// Verbose enables per-file / per-operation progress diagnostics on stderr
// during generation. Set by the CLI's --verbose flag; not serialised.
Verbose bool `yaml:"-"`
}
Config is the top-level .defederator.yml structure.
func LoadConfig ¶
LoadConfig reads and parses a .defederator.yml file. All relative paths inside the config are resolved relative to the file's directory.
func LoadConfigFromDir ¶
LoadConfigFromDir searches dir and its parents for a config file. Defederator files take precedence over genqlient files. When a genqlient config is found, LoadGenqlientConfig is used so the field mapping is correct.
In both cases the returned Config is validated — callers can rely on Schema, Client.Filename, and Client.Package all being non-empty.
func LoadGenqlientConfig ¶
LoadGenqlientConfig reads a genqlient.yaml file and converts it into a *Config suitable for defederator's generator. The SubgraphURLs field is left empty; callers must supply it via a sidecar .defederator.yml or a --subgraph-urls CLI flag.
func (*Config) ClientFilename ¶
ClientFilename returns the absolute path for the generated client file.
func (*Config) SchemaPath ¶
SchemaPath returns the absolute path to the supergraph SDL.
type GenerateConfig ¶
type GenerateConfig struct {
ClientInterfaceName *string `yaml:"clientInterfaceName,omitempty"`
// ExportOperations is a path to write a JSON manifest of all generated operations.
// Empty means no manifest is written.
ExportOperations string `yaml:"export_operations,omitempty"`
// Optional controls how nullable GraphQL fields are represented in Go.
// "pointer" (default): nullable T → *T; "value": nullable T → T (zero = absent).
Optional string `yaml:"optional,omitempty"`
}
GenerateConfig controls optional code-generation behaviours.
type PackageConfig ¶
PackageConfig specifies the output file and Go package name for generated code.
func (PackageConfig) IsDefined ¶
func (p PackageConfig) IsDefined() bool
IsDefined returns true if both Filename and Package are set.
type TypeBinding ¶
type TypeBinding struct {
Type string `yaml:"type"`
Marshaler string `yaml:"marshaler,omitempty"`
Unmarshaler string `yaml:"unmarshaler,omitempty"`
}
TypeBinding maps a GraphQL scalar name to a Go type with optional custom marshal/unmarshal functions, matching genqlient's bindings: format.