conventions icon indicating copy to clipboard operation
conventions copied to clipboard

The field 'viewer' of the subscription root type 'Subscription' must have StreamResolver set.

Open floge07 opened this issue 1 year ago • 5 comments

Hello,

I tried to update our GraphQL packages:

From: GraphQL: 7.2.0 GraphQL.Server.Transports.AspNetCore: 7.1.1 GraphQL.Convetions: 7.0.0

To: GraphQL: 8.2.1 GraphQL.Server.Transports.AspNetCore: 8.2.0 GraphQL.Convetions: 8.0.0

And now I'm seeing the following error, all graphql execution fails.

Error executing document. The schema is invalid. See inner exceptions for details. (The field 'viewer' of the subscription root type 'Subscription' must have StreamResolver set.) (The field 'method1' of an Object type 'SubscriptionViewer' must not have StreamResolver set. You should set StreamResolver only for the root fields of subscriptions.) (The field 'method2' of an Object type 'SubscriptionViewer' must not have StreamResolver set. You should set StreamResolver only for the root fields of subscriptions.) (The field 'method3' of an Object type 'SubscriptionViewer' must not have StreamResolver set. You should set StreamResolver only for the root fields of subscriptions.) (The field 'method4' of an Object type 'SubscriptionViewer' must not have StreamResolver set. You should set StreamResolver only for the root fields of subscriptions.)

*I censored the field names.

What exactly does this mean? What of the types would you need to see to trace this issue?

Our Root GraphQL Types (Queries, Mutations, Subscriptions) on different services inherit from a base class (which defines some common things). Is this a problem?

floge07 avatar Dec 12 '24 10:12 floge07

Ok, now I tried to use all the latest 7.x releases. Similar problem but smaller error message.

Error executing document. The field 'viewer' of the subscription root type 'Subscription' must have StreamResolver set.

floge07 avatar Dec 12 '24 10:12 floge07

Looks similar: #258

floge07 avatar Dec 12 '24 10:12 floge07

I solved it by removing

[ImplementViewer(OperationType.Subscription)]
[ImplementViewer(OperationType.Query)]
[ImplementViewer(OperationType.Mutation)]

from the root types... I don't even remember what this was for.

floge07 avatar Dec 12 '24 11:12 floge07

Sorry, I know little about the Conventions project, and it seems you have a solution anyway.

Shane32 avatar Dec 13 '24 14:12 Shane32

Well I leave it to you to figure out what to do with this problem. Whether this is wrong or intended behavior, or whether you simply mention it in some migration guide.

One last question though, if someone could answer what these were even for, that would be helpful. Always scary to remove something in a big code base, which on first glance didn't change anything.

floge07 avatar Dec 13 '24 16:12 floge07