Skip to content

Commit 3d6864e

Browse files
committed
Introduce ResolveMetaFieldValue algorithm
1 parent 1e48b21 commit 3d6864e

File tree

1 file changed

+32
-10
lines changed

1 file changed

+32
-10
lines changed

spec/Section 6 -- Execution.md

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -581,14 +581,12 @@ variableValues):
581581
- For each {responseName} and {fields} in {collectedFieldsMap}:
582582
- Let {fieldName} be the name of the first entry in {fields}. Note: This value
583583
is unaffected if an alias is used.
584-
- If {fieldName} is a meta-field as defined in the Introspection section:
585-
- Let {responseValue} be the result of resolving that meta-field as per the
586-
rules of the [Introspection](#sec-Introspection) section.
587-
- Set {responseValue} as the value for {responseName} in {resultMap}.
588-
- Otherwise, if a field named {fieldName} is defined on {objectType}:
589-
- Let {fieldType} be the return type defined for the field {fieldName} of
590-
{objectType}.
591-
- Assert: {fieldType} must exist.
584+
- If {fieldName} is a meta-field as defined in the
585+
[Introspection](#sec-Introspection) section, let {fieldType} be the return
586+
type of that meta-field.
587+
- Otherwise, let {fieldType} be the return type defined for the field
588+
{fieldName} of {objectType}.
589+
- If {fieldType} is defined:
592590
- Let {responseValue} be {ExecuteField(objectType, objectValue, fieldType,
593591
fields, variableValues)}.
594592
- Set {responseValue} as the value for {responseName} in {resultMap}.
@@ -730,8 +728,11 @@ ExecuteField(objectType, objectValue, fieldType, fields, variableValues):
730728
- Let {fieldName} be the field name of {field}.
731729
- Let {argumentValues} be the result of {CoerceArgumentValues(objectType, field,
732730
variableValues)}.
733-
- Let {resolvedValue} be {ResolveFieldValue(objectType, objectValue, fieldName,
734-
argumentValues)}.
731+
- If {fieldName} is a meta-field as defined in the
732+
[Introspection](#sec-Introspection) section, let {resolvedValue} be
733+
{ResolveMetaFieldValue(objectType, fieldName, argumentValues)}.
734+
- Otherwise, let {resolvedValue} be {ResolveFieldValue(objectType, objectValue,
735+
fieldName, argumentValues)}.
735736
- Return the result of {CompleteValue(fieldType, fields, resolvedValue,
736737
variableValues)}.
737738

@@ -823,6 +824,27 @@ necessitates the rest of a GraphQL executor to handle an asynchronous execution
823824
flow. If the field is of a list type, each value in the collection of values
824825
returned by {resolver} may itself be retrieved asynchronously.
825826

827+
### Meta-Field Resolution
828+
829+
The meta-fields `__typename`, `__schema` and `__type` are resolved as per the
830+
rules in the [Introspection](#sec-Introspection) section.
831+
832+
ResolveMetaFieldValue(objectType, fieldName, argumentValues):
833+
834+
- If {fieldName} is {"\_\_typename"}:
835+
- Return the name of {objectType}.
836+
- If {fieldName} is {"\_\_schema"}:
837+
- Assert: {objectType} must be the _root operation type_ in {schema} for query
838+
operations.
839+
- Return {schema}.
840+
- If {fieldName} is {"\_\_type"}:
841+
- Assert: {objectType} must be the _root operation type_ in {schema} for query
842+
operations.
843+
- Let {typeName} be the value provided in {argumentValues} for the name
844+
{"name"}.
845+
- Let {type} be the type with name {typeName} in {schema}.
846+
- Return {type} if it exists; otherwise {null}.
847+
826848
### Value Completion
827849

828850
After resolving the value for a field, it is completed by ensuring it adheres to

0 commit comments

Comments
 (0)