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

Resolve Promise references for interface types before handing off to resolveType fn #2556

Merged

Conversation

trevor-scheer
Copy link
Member

@trevor-scheer trevor-scheer commented May 2, 2023

Fixes #2552

Commits in order first reproduce the issue then resolve it.

Interface entities are a relatively new thing, but I'm surprised this hasn't surfaced yet since it seems like it'd be a showstopper for anyone trying to use it. If my understanding of the issue is correct, this seems like a reasonable solution... though it's possible the issue is wrong.

FWIW, none of our __resolveReference functions in tests return Promises, it might be more realistic if they did.

@changeset-bot
Copy link

changeset-bot bot commented May 2, 2023

🦋 Changeset detected

Latest commit: 5a1b8a2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@apollo/subgraph Patch
@apollo/federation-internals Patch
@apollo/gateway Patch
@apollo/composition Patch
@apollo/query-planner Patch
@apollo/query-graphs Patch
apollo-federation-integration-testsuite Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@netlify
Copy link

netlify bot commented May 2, 2023

Deploy Preview for apollo-federation-docs canceled.

Name Link
🔨 Latest commit 5a1b8a2
🔍 Latest deploy log https://app.netlify.com/sites/apollo-federation-docs/deploys/6453e809344d3100081ade50

@codesandbox-ci
Copy link

codesandbox-ci bot commented May 2, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@trevor-scheer trevor-scheer marked this pull request as ready for review May 2, 2023 22:19
@trevor-scheer trevor-scheer requested a review from a team as a code owner May 2, 2023 22:19
Copy link
Contributor

@pcmanus pcmanus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do think this is the issue and the fix looks good to me.

Testing wise, I'll note that there is few variants on how you can make this work: you can skip the __resolveType but return the __typename in the __resolveReference instead, or you can use isTypeOf for instance, and those variants are tested here, but indeed only for there synchronous versions. It might be nice to try to modify this (parameterised) test to include asynchronous variants of the various options. In particular, the added test in this patch tests an async __resolveReference but a sync __resolveType, but you can also have async __resolveType (with or without async __resolveReference), and while I believe the code is fine for those now, would be nice to cover everything.

@trevor-scheer trevor-scheer force-pushed the trevor/2552-subgraph-interface-resolve-type-issue branch from 3c65af6 to c437d6e Compare May 3, 2023 18:22
@trevor-scheer trevor-scheer merged commit 53fe448 into main May 4, 2023
14 checks passed
@trevor-scheer trevor-scheer deleted the trevor/2552-subgraph-interface-resolve-type-issue branch May 4, 2023 17:27
@github-actions github-actions bot mentioned this pull request May 4, 2023
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.

__resolveType receiving Promise after __resolveReference for interfaces
2 participants