-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve
Promise
references for interface types before handing off t…
…o `resolveType` fn (#2556) Since the introduction of entity interfaces, users could not return a `Promise` from `__resolveReference` while implementing a synchronous, custom `__resolveType` function. This change fixes/permits this use case. Additional background / implementation details: Returning a `Promise` from `__resolveReference` has historically never been an issue. However, with the introduction of entity interfaces, the calling of an interface's `__resolveType` function became a new concern. `__resolveType` functions expect a reference (and shouldn't be concerned with whether those references are wrapped in a `Promise`). In order to address this, we can `await` the reference before calling the `__resolveType` (this handles both the non-`Promise` and `Promise` case).
- Loading branch information
1 parent
eb5c104
commit 53fe448
Showing
4 changed files
with
165 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
"@apollo/subgraph": patch | ||
--- | ||
|
||
Resolve `Promise` references before calling `__resolveType` on interface | ||
|
||
Since the introduction of entity interfaces, users could not return | ||
a `Promise` from `__resolveReference` while implementing a synchronous, | ||
custom `__resolveType` function. This change fixes/permits this use case. | ||
|
||
Additional background / implementation details: | ||
|
||
Returning a `Promise` from `__resolveReference` has historically never | ||
been an issue. However, with the introduction of entity interfaces, the | ||
calling of an interface's `__resolveType` function became a new concern. | ||
|
||
`__resolveType` functions expect a reference (and shouldn't be concerned | ||
with whether those references are wrapped in a `Promise`). In order to | ||
address this, we can `await` the reference before calling the | ||
`__resolveType` (this handles both the non-`Promise` and `Promise` case). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters