apollo-federation-ruby icon indicating copy to clipboard operation
apollo-federation-ruby copied to clipboard

fix: Adds support for defining Interface entities resolvers

Open moonflare opened this issue 1 year ago • 5 comments

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:

  1. 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
  2. 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 in GraphQL can't be an Interface 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 allow Interfaces (more precisely Modules) as possible types.
  • 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 the Interface module. This commit adds the same underscore_reference_keys method to the Interface module.
  • Adds some docs for the Interface Entities feature support.

cc @nogates

moonflare avatar Sep 13 '23 07:09 moonflare

Hey @grxy! Could you please have a look at this PR when time allows? 🙏🏻

moonflare avatar Sep 14 '23 13:09 moonflare

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! 🙏

grxy avatar Sep 14 '23 17:09 grxy

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 :)

nogates avatar Oct 03 '23 12:10 nogates

Thanks @sofie-c ! I will have a look this week or early next week :)

nogates avatar Nov 06 '23 11:11 nogates

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?

craig-day avatar Jun 03 '24 15:06 craig-day