apollo-federation-ruby
apollo-federation-ruby copied to clipboard
fix: Adds support for defining Interface entities resolvers
Context
As part of the Federation v2.3 spec, the Apollo team added a new feature, to support defining and referencing Entities that are interfaces. You can read more about this here, and check the initial implementation here.
This feature consists of two parts:
- An Interface Entity defined in Subgraph A can be referenced from Subgraph B using the
@interfaceObject
directive. This work was added in https://github.com/Gusto/apollo-federation-ruby/pull/218 - An Interface Entity can be defined in your subgraph. This part is missing and this is what this PR adds.
Description
- Updates the Union validation so we can allow an interface to be a union member
- The main issue here is the fact that an
Union
inGraphQL
can't be anInterface
according to the spec, but at the same time, according to the Apollo Federation spec, an interface can be an Entity, and an Entity is an Union. Therefore, we have to extend the validation (assert_valid_union_member
) for the Entity union to allowInterfaces
(more preciselyModules
) as possible types.
- The main issue here is the fact that an
- Adds validation that all implementing types of an Entity Interface also have the
@key
directive. This is a requirement from the spec. - Adds
underscore_reference_keys
support to interfaces- In a previous Pull Request (#248) there was added support for underscoring the keys and while this covered the
Object
class, it didn't also cover theInterface
module. This commit adds the sameunderscore_reference_keys
method to theInterface
module.
- In a previous Pull Request (#248) there was added support for underscoring the keys and while this covered the
- Adds some docs for the
Interface Entities
feature support.
cc @nogates
Hey @grxy! Could you please have a look at this PR when time allows? 🙏🏻
Hey there @moonflare. We are in the midst of a team shuffle so reviewing this will be delayed. Thanks for the PR and for your patience! 🙏
Hey there @moonflare. We are in the midst of a team shuffle so reviewing this will be delayed. Thanks for the PR and for your patience! 🙏
Hey @grxy !
Sorry to ask, but do you when you will have time to look at this? We are going to need this pretty soon and we would love to see the code here :)
Thanks @sofie-c ! I will have a look this week or early next week :)
Hey @sofie-c and @sethc2 after some moving around on our side as well, I'm going to pick this work up from @moonflare. Do we still want to keep things in this PR, or would you be OK with me opening up a new PR based on the latest main?