From 413b68974ef86b6cc8a9272bbc8360762eee3479 Mon Sep 17 00:00:00 2001 From: Benjie Gillam Date: Thu, 15 Apr 2021 18:48:36 +0100 Subject: [PATCH] RFC: __typename is not valid at subscription root (#776) * __typename is not valid at subscription root * Update spec edits based on Lee's comments * Simplify * Clarify * Typo * Update Section 5 -- Validation.md Co-authored-by: Lee Byron --- spec/Section 4 -- Introspection.md | 2 ++ spec/Section 5 -- Validation.md | 10 ++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/Section 4 -- Introspection.md b/spec/Section 4 -- Introspection.md index 42572ed9c..6f9b2e99b 100644 --- a/spec/Section 4 -- Introspection.md +++ b/spec/Section 4 -- Introspection.md @@ -101,6 +101,8 @@ identify which actual Object type of the possible types has been returned. As a meta-field, `__typename` is implicit and does not appear in the fields list in any defined type. +Note: `__typename` may not be included as a root field in a subscription +operation. ## Schema Introspection diff --git a/spec/Section 5 -- Validation.md b/spec/Section 5 -- Validation.md index f56c0f2d6..34b99820d 100644 --- a/spec/Section 5 -- Validation.md +++ b/spec/Section 5 -- Validation.md @@ -255,7 +255,8 @@ query getName { * Let {variableValues} be the empty set. * Let {groupedFieldSet} be the result of {CollectFields(subscriptionType, selectionSet, variableValues)}. -* {groupedFieldSet} must have exactly one entry. +* {groupedFieldSet} must have exactly one entry, which must not be an + introspection field. **Explanatory Text** @@ -311,14 +312,11 @@ fragment multipleSubscriptions on Subscription { } ``` -Introspection fields are counted. The following example is also invalid: +The root field of a subscription operation must not be an introspection field. +The following example is also invalid: ```graphql counter-example subscription sub { - newMessage { - body - sender - } __typename } ```