Open Yamashou opened 4 years ago
Subscription
is a reserved GraphQL type, and thus, the error you're facing is likely due to the code generator failing to process the duplication. I believe an error is desired, but errors like this could stand to have a more specific message.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
A more specific message would be very helpful here. I had no trouble defining a Subscription object type in my GraphQL schema which works just fine between Apollo and our GraphQL Ruby server. When generating client code with this library, however, I receive a somewhat confusing panic, Subscription was not found
(when, in fact, it's a misuse of a reserved type):
2021/06/25 13:18:14 Subscription was not found
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x12e461f]
goroutine 1 [running]:
github.com/99designs/gqlgen/codegen/config.(*TypeReference).IsPtr(...)
/Users/parkr/go/pkg/mod/github.com/99designs/gqlgen@v0.10.2/codegen/config/binder.go:255
github.com/99designs/gqlgen/codegen.(*builder).buildField(0xc002bdbbc8, 0xc001187c80, 0xc0051f8380, 0x0, 0x1, 0xc000d8e958)
/Users/parkr/go/pkg/mod/github.com/99designs/gqlgen@v0.10.2/codegen/field.go:70 +0x37f
github.com/99designs/gqlgen/codegen.(*builder).buildObject(0xc002bdbbc8, 0xc0051f6540, 0xc001187c00, 0x0, 0x0)
/Users/parkr/go/pkg/mod/github.com/99designs/gqlgen@v0.10.2/codegen/object.go:73 +0x47f
github.com/99designs/gqlgen/codegen.BuildData(0xc0001f4000, 0xc0001f4000, 0x0, 0x0)
/Users/parkr/go/pkg/mod/github.com/99designs/gqlgen@v0.10.2/codegen/data.go:89 +0x4ac
It is interesting – given that Apollo and GraphQL Ruby seem to accept this Subscription type, perhaps it is not unreasonable to support Subscription implements Node
as an object type?
@vektah It looks like Subscription
is just a default root type name, which means it could easily be renamed and it's perfectly valid for us to use Subscription
as a non-subscription object type. https://spec.graphql.org/draft/#sec-Root-Operation-Types.Default-Root-Operation-Type-Names
From my reading, if the Schema's subscriptionType
is null
, then subscriptions are not supported.
Hi,
In my case that's different, I'm from the v0.11.3
upgrading to latest... but now I no longer have a SubscriptionResolver
, it's generated as a basic struct type. So my running server won't serve subscriptions 😢
I didn't see any mention of this, do you know how can I fix this? @lwc @vektah
Thanks
EDIT:
Ok it seems the behavior has changed and now it needs to be explicitly into the schema
:
What happened?
A panic occurs if define type of Subscription
What did you expect?
No Panic and generate code
Minimal graphql.schema and models to reproduce
versions
gqlgen version
? v0.10.2go version
? go version go1.12.9 darwin/amd64