Upcoming Potentially Breaking Changes Warning
This release has changes in the Federation plugin, introducing opt-in changes that will become the default in the next release (v0.17.95).
When configured, the federation plugin creates an entity resolver that accepts a list of representations, improving performance by reducing the number of individual resolver calls.
// IMPORTANT: The output slice order is critical and must match the input slice order exactly!
func (r *entityResolver) FindUserByIDs(ctx context.Context, reps []*entity.UserByIDsInput) ([]*model.User, error) {
output := make([]*model.User, len(reps))
for i, user := range reps {
output[i] = &model.User{
ID: user.ID,
Name: "User " + user.ID,
}
}
return output, nil
}
The @entityResolver directive enables optimization for entity resolver generation in GraphQL federation, and can be opted in by specifying multi: true as in:
type MultiHello @key(fields: "name") @entityResolver(multi: true)
Or you can enable this feature by default by setting the federation.options.entity_resolver_multi flag in your configuration:
federation:
filename: graph/federation.go
package: graph
version: 2
options:
entity_resolver_multi: true
What's Changed
- fix(federation): disambiguate colliding key-field Go names in multi-resolvers by @StevenACoffman in #4241
- fix(federation): return a positioned validation error for @key referencing an undeclared field by @StevenACoffman in #4249
- Federation: per-entity @requires strategies with preloaded batch delivery by @StevenACoffman in #4242
- Update github.com/gqlparser/vektah/gqlparser/v2 to v2.5.36 by @StevenACoffman in #4250
- chore: drop dead vSlice predecl in codegen template by @c-tonneslan in #4197
- Disable scalar leaf suggestions when requested by @XuankangLin in #4252
- feat(federation): per-field computed @requires via @computedRequires by @StevenACoffman in #4251
- Fix panic when resolver returns a nil pointer to a slice or any by @surbhi-singh in #4256
- fix:
@goEmbedInterfacegenerating double-pointer getters for nullable fields by @adrianlungu in #4258 - Update to golang.org/x/text@v0.40.0 and golang.org/x/sync@v0.22.0 and golang.org/x/tools@v0.48.0 and golang.org/x/net@v0.57.0 by @StevenACoffman in #4259
- chore(deps): bump github.com/urfave/cli/v3 from 3.10.0 to 3.10.1 by @dependabot[bot] in #4246
- chore(deps): bump actions/setup-go from 6.4.0 to 6.5.0 by @dependabot[bot] in #4244
- chore(deps-dev): bump urql from 5.0.2 to 5.0.3 in /integration by @dependabot[bot] in #4245
- chore(deps): bump golang.org/x/tools from 0.46.0 to 0.47.0 by @dependabot[bot] in #4247
New Contributors
- @XuankangLin made their first contribution in #4252
- @surbhi-singh made their first contribution in #4256
Full Changelog: v0.17.93...v0.17.94