v0.19.3.0
ElasticGraph v0.19.3.0 has been released! This release includes a couple of new features, some bug fixes, and a minor breaking change.
New Feature: Field-level Custom Resolver Arguments
We added a custom GraphQL resolver API in ElasticGraph v0.19.2.0. That release allowed the same resolver class to be used with different parameters by registering it multiple times:
require(require_path = "roll_dice_resolver")
schema.register_graphql_resolver :roll_2_dice,
RollDiceResolver,
defined_at: require_path,
number_of_dice: 2
schema.register_graphql_resolver :roll_3_dice,
RollDiceResolver,
defined_at: require_path,
number_of_dice: 3
schema.on_root_query_type do |t|
t.field "roll2Dice", "Int" do |f|
f.resolve_with :roll_2_dice
end
t.field "roll3Dice", "Int" do |f|
f.resolve_with :roll_3_dice
end
endElasticGraph v0.19.3.0 allows you to provide these parameters at the field level when configuring a field to use a resolver:
require(require_path = "roll_dice_resolver")
schema.register_graphql_resolver :roll_dice,
RollDiceResolver,
defined_at: require_path
schema.on_root_query_type do |t|
t.field "roll2Dice", "Int" do |f|
f.resolve_with :roll_dice, number_of_dice: 2
end
t.field "roll3Dice", "Int" do |f|
f.resolve_with :roll_dice, number_of_dice: 3
end
endImproved Apollo Federation Support
Apollo Federation provides a powerful way to combine multiple subgraphs into a single supergraph. ElasticGraph has shipped with the elasticgraph-apollo extension for a long time, which makes any ElasticGraph project plug into an Apollo supergraph as a subgraph.
However, ElasticGraph schemas haven't always lined up with Apollo federation idioms. To expose a reference to an Apollo entity, a subgraph needs to expose an entity reference containing a non-resolvable entity with just the @key fields:
type Product @key(fields: "id", resolvable: false) {
id: ID
}The ElasticGraph schema would then expose fields like product: Product or products: [Product!]! rather than productId: ID or productIds: [ID!]!. However, if your schema already has a productId field, migrating to the entity reference can be a significant effort, requiring clients to migrate and a backfill.
ElasticGraph v0.19.3.0 includes a new feature to help out in this situation. Here's how to use it:
# Existing field
t.field "productId", "ID"
# New field defined with the new feature
t.apollo_entity_ref_field "product", "Product", id_field_name_in_index: "productId"This exposes a Product field backed by the productId field.
You can also use this on a collection of IDs:
# Existing field
t.field "productIds", "[ID!]!"
# New field defined with the new feature
t.apollo_entity_ref_field "products", "[Product!]!", id_field_name_in_index: "productIds"Or, if you want to provide a paginated collection as a relay connection:
# Existing field
t.field "productIds", "[ID!]!"
# New field defined with the new feature
t.apollo_entity_ref_paginated_collection_field "products", "Product", id_field_name_in_index: "productIds"Upgrade Notes
This release includes a minor breaking change to the custom GraphQL resolver API added in v0.19.2.0. Previously, this was the API to configure a field to use a custom resolver:
schema.on_root_query_type do |t|
t.field "rollDice", "Int" do |f|
f.resolver = :roll_dice
end
endIn ElasticGraph v0.19.3.0, that's changed slightly:
schema.on_root_query_type do |t|
t.field "rollDice", "Int" do |f|
f.resolve_with :roll_dice
end
endIf your project uses custom resolvers (which is not common), you'll need to update to the new API as part of upgrading ElasticGraph.
What's Changed
New Features
- Improve
paginated_collection_field: support more field options. by @myronmarston in #606 - Support field-level custom resolver arguments. by @myronmarston in #603 and #604
- Provide
apollo_entity_ref_fieldto expose an id field as an entity ref. by @myronmarston in #611 - Add
request_all_fieldstoDatastoreQuery. by @myronmarston in #537
Breaking Changes
- Breaking change: improve schema definition resolver API. by @myronmarston in #602
Bug Fixes
- Avoid requesting non-existent subfields of a scalar field. by @myronmarston in #607
- Improve handling of
name_in_indexon agraphql_onlyfield. by @myronmarston in #609 - Fix pagination bugs on
paginated_collection_fieldfields. by @myronmarston in #610
Other Improvements
- Setup infrastructure for AI agent coding including a memory bank. by @myronmarston in #614
- Refresh README and improve YARD markdown rendering. by @myronmarston in #615
- Correct a couple of things in our guides at the website. by @myronmarston in #616
Full Changelog: v0.19.2.2...v0.19.3.0