RFC: __typename should be valid at subscription root #806
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an alternative solution to #776 wherein
__typenameis explicitly allowed inspired by @IvanGoncharov's comment on that PR.Description of issue
__typenamedoes not return an event stream, so it does not make sense to allow for it to be the source stream in a GraphQL subscription operation. As currently specified, the following query passes validation, but it should always produce an error since the ResolveFieldEventStream algorithm cannot resolve a subscriptionresolverfor__typename:Separately; it's valid to add
__typenameto any selection set in any GraphQL operation except the root selection set (including fragments) on a Subscription operation. This exclusion complicates life for various GraphQL tooling; it's desirable that this (currently invalid) GraphQL operation be valid:The current GraphQL algorithm for subscriptions operates in two steps; first it resolves the "source stream" from the root field that will generate the subscription events, and then when an event is received it executes the entire operation (NOTE: not just the selection set of the source stream's field, but the entire selection set of the operation) using this event as the
initialValue. As such,__typenamecould be valid in the root selection set so long as there is exactly one field capable of providing the source stream.Solution outline
CreateSourceEventStreamsuch that it uses this non-introspection field as the event source (i.e. so that it ignores introspection fields).