Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate federation entity resolvers for interfaces with @key fields defined #2634

Merged
merged 1 commit into from
May 11, 2023

Conversation

nicolerenee
Copy link
Contributor

When using interfaces and interfaceObjects as described by the Apollo spec you have to be able to resolve the interface types as described here.

This updates the generation to allow @key fields on interfaces and generates the resulting functions needed to handling resolving the entities.

I left the existing test but changed it to be an unused interface, and then created a new test with an interface that is used to verify it works. I've also validated this works with the federated gateway to properly handle resolving interface return types coming from a different subgraph.

The only thing I'm not sure about is around line 223. I'm using an object that implements the interface to get the field types. This seemed easier to maintain long term as it seemed like I would need to fork to code and have one path for an interface and one path for an object since there isn't an object for the interface. Open to ideas to improve this though.

Not sure if any docs specifically for this are desired, the use of @key fields is documented already and it follows the same pattern.

I have:

  • Added tests covering the bug / feature (see testing)
  • Updated any relevant documentation (see docs)

Signed-off-by: Nicole Hubbard <code@nicole.dev>
@coveralls
Copy link

Coverage Status

Coverage: 75.439% (-3.4%) from 78.807% when pulling 8f55996 on nicolerenee:fed-interface-gen into 82a110c on 99designs:master.

@StevenACoffman
Copy link
Collaborator

I can't tell you how thrilled I am that you worked on this! Better federation support has been long desired. And you even thought about maintainability!

@StevenACoffman StevenACoffman merged commit 9796f91 into 99designs:master May 11, 2023
@nicolerenee nicolerenee deleted the fed-interface-gen branch May 11, 2023 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants