So imagine the following basic schema:
type Query {
foo(tag: String): MetadataItem
}
type Subscription {
foo(tag: String): MetadataItem
}
My resolver for Query.foo can return a Promise<MetadataItem>.
You would think my subscribe resolver could return an AsyncIterable<MetadataItem>.
But noooo...
For whatever reason it has to return an AsyncIterable<{foo: MetadataItem}>.
Why do I have to wrap the values I yield in an object?
Is there a good reason for this or is it just a mistake?
This is really annoying and it always trips me up. Why were subscriptions designed this way instead of being more consistent with queries? I feel very angry about how often I have had to debug issues stemming from this, because it's just not an intuitive inconsistency. It's very easy to forget about.
GraphQL could so easily wrap the values I yield in an object with the field name, the only reason I can imagine that it doesn't is some performance nitpick.