diff --git a/spec/Section 6 -- Execution.md b/spec/Section 6 -- Execution.md index c615e526e..540539361 100644 --- a/spec/Section 6 -- Execution.md +++ b/spec/Section 6 -- Execution.md @@ -581,8 +581,11 @@ variableValues): - For each {responseName} and {fields} in {collectedFieldsMap}: - Let {fieldName} be the name of the first entry in {fields}. Note: This value is unaffected if an alias is used. - - Let {fieldType} be the return type defined for the field {fieldName} of - {objectType}. + - If {fieldName} is a meta-field as defined in the + [Introspection](#sec-Introspection) section, let {fieldType} be the return + type of that meta-field. + - Otherwise, let {fieldType} be the return type defined for the field + {fieldName} of {objectType}. - If {fieldType} is defined: - Let {responseValue} be {ExecuteField(objectType, objectValue, fieldType, fields, variableValues)}. @@ -725,8 +728,11 @@ ExecuteField(objectType, objectValue, fieldType, fields, variableValues): - Let {fieldName} be the field name of {field}. - Let {argumentValues} be the result of {CoerceArgumentValues(objectType, field, variableValues)}. -- Let {resolvedValue} be {ResolveFieldValue(objectType, objectValue, fieldName, - argumentValues)}. +- If {fieldName} is a meta-field as defined in the + [Introspection](#sec-Introspection) section, let {resolvedValue} be + {ResolveMetaFieldValue(objectType, fieldName, argumentValues)}. +- Otherwise, let {resolvedValue} be {ResolveFieldValue(objectType, objectValue, + fieldName, argumentValues)}. - Return the result of {CompleteValue(fieldType, fields, resolvedValue, variableValues)}. @@ -818,6 +824,30 @@ necessitates the rest of a GraphQL executor to handle an asynchronous execution flow. If the field is of a list type, each value in the collection of values returned by {resolver} may itself be retrieved asynchronously. +### Meta-Field Resolution + +The meta-fields `__typename`, `__schema` and `__type` are resolved as per the +rules in the [Introspection](#sec-Introspection) section. + +ResolveMetaFieldValue(objectType, fieldName, argumentValues): + +- If {fieldName} is {"\_\_schema"}: + - Assert: {objectType} must be the _root operation type_ in {schema} for query + operations. + - Return {schema}. +- Otherwise, if {fieldName} is {"\_\_type"}: + - Assert: {objectType} must be the _root operation type_ in {schema} for query + operations. + - Let {typeName} be the value provided in {argumentValues} for the name + {"name"}. + - If {typeName} begins with {"\_\_"}, let {type} be the type with name + {typeName} in the introspection schema. + - Otherwise, let {type} be the type with name {typeName} in {schema}. + - Return {type} if it exists; otherwise {null}. +- Otherwise: + - Assert: {fieldName} is {"\_\_typename"}. + - Return the name of {objectType}. + ### Value Completion After resolving the value for a field, it is completed by ensuring it adheres to