Skip to content

Commit ef0449d

Browse files
committed
Introduce ResolveMetaFieldValue algorithm
1 parent 1e48b21 commit ef0449d

File tree

1 file changed

+31
-10
lines changed

1 file changed

+31
-10
lines changed

spec/Section 6 -- Execution.md

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -581,14 +581,11 @@ 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; otherwise let {fieldType} be the return type
587+
defined for the field {fieldName} of {objectType}.
588+
- If {fieldType} is defined:
592589
- Let {responseValue} be {ExecuteField(objectType, objectValue, fieldType,
593590
fields, variableValues)}.
594591
- Set {responseValue} as the value for {responseName} in {resultMap}.
@@ -730,8 +727,11 @@ ExecuteField(objectType, objectValue, fieldType, fields, variableValues):
730727
- Let {fieldName} be the field name of {field}.
731728
- Let {argumentValues} be the result of {CoerceArgumentValues(objectType, field,
732729
variableValues)}.
733-
- Let {resolvedValue} be {ResolveFieldValue(objectType, objectValue, fieldName,
734-
argumentValues)}.
730+
- If {fieldName} is a meta-field as defined in the
731+
[Introspection](#sec-Introspection) section, let {resolvedValue} be
732+
{ResolveMetaFieldValue(objectType, fieldName, argumentValues)}.
733+
- Otherwise, let {resolvedValue} be {ResolveFieldValue(objectType, objectValue,
734+
fieldName, argumentValues)}.
735735
- Return the result of {CompleteValue(fieldType, fields, resolvedValue,
736736
variableValues)}.
737737

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

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

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

0 commit comments

Comments
 (0)