Documentation
¶
Overview ¶
Package defederator executes a pre-built federation Plan against subgraph HTTP endpoints. It has no dependency on the query planner — all routing decisions (which subgraph owns which field, key fields for entity resolution, etc.) are encoded in the Plan at build time.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecuteAndUnmarshal ¶
func ExecuteAndUnmarshal( ctx context.Context, plan *Plan, vars any, client *http.Client, dest any, ) error
ExecuteAndUnmarshal runs plan and JSON-unmarshals the merged result into dest.
Fast path: when the plan has exactly one fetch and no entity fetches, the subgraph response is unmarshaled directly into dest — no intermediate map[string]any allocation or re-marshal step.
Types ¶
type EntityFetch ¶
type EntityFetch struct {
URL string
TypeName string
KeyFields []string
RequiresFields []string
Selection string // GraphQL selection body, e.g. "email\nname\n"
Query string // full entity query with variable declarations; supersedes Selection when non-empty
Variables []string // operation variable names to forward beyond "representations"
ParentPath []string // JSON path to the parent object in merged data
IsParentList bool
}
EntityFetch resolves cross-subgraph entity fields after the initial fetches complete.
type Fetch ¶
type Fetch struct {
URL string
Query string
Variables []string // variable names from the outer operation used by this fetch
}
Fetch is a query to send to one subgraph URL.
type FieldProjection ¶
type FieldProjection struct {
Key string `json:"Key"`
Children []*FieldProjection `json:"Children,omitempty"`
}
FieldProjection is a node in the user-requested selection tree. Used to strip planner-added fields (key fields, __typename, @requires pre-fetch fields) from the final merged response.
type GraphQLError ¶
type GraphQLError struct {
Message string `json:"message"`
Locations []map[string]int `json:"locations,omitempty"`
Path []any `json:"path,omitempty"`
Extensions map[string]any `json:"extensions,omitempty"`
}
GraphQLError is a single error object in a GraphQL response.
func (GraphQLError) Error ¶
func (e GraphQLError) Error() string
type Plan ¶
type Plan struct {
Fetches []Fetch
EntityFetches []EntityFetch
Projection []*FieldProjection
}
Plan is a fully resolved execution plan. URLs are baked in at plan-build time; no routing table is needed at execute time.
func Resolve ¶
Resolve decodes a JSON-encoded plan spec and returns a Plan with subgraph enum names substituted by their URLs from urls. Returns an error if any enum name is absent from urls.
func ResolveURLSpec ¶
ResolveURLSpec decodes a URL-keyed JSON plan spec into a Plan. Unlike Resolve, it requires no URL map — subgraph URLs are embedded in the spec JSON.