Skip to content

Commit 13eb991

Browse files
committed
Allow recursion within ResolveAbstractType
This formalizes the proprosed feature within `graphql-js` whereby the internal method provided by JavaScript for runtime type resolution is allowed to return an intermediate interface. See: Issue: graphql/graphql-js#3253 PR: graphql/graphql-js#3599 @IvanGoncharov [suggested](graphql/graphql-js#3599 (review)) that this would require a spec change. Alternatively, perhaps the recursion [should be considered to be a feature of the internal system](graphql/graphql-js#3599 (comment)) itself, possibly limited to JavaScript-like implementations. This PR provides some potential spec text, were a spec change to be considered necessary.
1 parent 4de8782 commit 13eb991

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

spec/Section 6 -- Execution.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -722,18 +722,27 @@ and output of {CoerceResult()} must not be {null}.
722722

723723
When completing a field with an abstract return type, that is an Interface or
724724
Union return type, first the abstract type must be resolved to a relevant Object
725-
type. This determination is made by the internal system using whatever means
726-
appropriate.
725+
type. The internal system must provided a method for doing so using whatever
726+
means appropriate.
727+
728+
Note: In cases where interfaces may implement interfaces, creating an abstract
729+
type hierarchy, the provided internal method may find it convenient on some
730+
systems to return an intermediate Interface type rather than the runtime Object
731+
type, requiring recursion, as detailed below.
727732

728733
Note: A common method of determining the Object type for an {objectValue} in
729734
object-oriented environments, such as Java or C#, is to use the class name of
730735
the {objectValue}.
731736

732737
ResolveAbstractType(abstractType, objectValue):
733738

734-
- Return the result of calling the internal method provided by the type system
735-
for determining the Object type of {abstractType} given the value
739+
- Let {possibleRuntimeType} be the result of calling the internal method
740+
provided by the type system, given Abstract type {abstractType} and value
736741
{objectValue}.
742+
- If {possibleRuntimeType} is an Object type:
743+
- Return {possibleRuntimeType}.
744+
- If {possibleRuntimeType} is an Interface type:
745+
- Return ResolveAbstractTypeImpl(possibleRuntimeType, objectValue).
737746

738747
**Merging Selection Sets**
739748

0 commit comments

Comments
 (0)