gqlgen: Apollo Federation: 422: Unprocessable Entity when no entity defined
What happened?
There is a service which only contains a mutation which has only input types defined:
extend type Mutation {
addSurveyResult(result: SurveyResult!): ID
}
input SurveyResultTuple {
key: String
value: String
}
input SurveyResult {
userId: ID!
type: String!
elements: [SurveyResultTuple!]!
}
when I try to federate the service by a gateway the following errors occure:
Service:
unknown field “_service”
goroutine 9 [running]: runtime/debug.Stack(0x1, 0x0, 0x0) /usr/local/go/src/runtime/debug/stack.go:24 +0x9d runtime/debug.PrintStack() /usr/local/go/src/runtime/debug/stack.go:16 +0x22 github.com/99designs/gqlgen/graphql.DefaultRecover(0xc0c740, 0xc0002c8690, 0x9fe620, 0xc0001b8de0, 0x44900f, 0x18) /home/simon/go/pkg/mod/github.com/99designs/gqlgen@v0.11.1/graphql/recovery.go:16 +0xa7 github.com/99designs/gqlgen/graphql/handler.(*Server).ServeHTTP.func1(0xc0000d5e40, 0xc00013fbd0, 0xc0ae40, 0xc0002922a0) /home/simon/go/pkg/mod/github.com/99designs/gqlgen@v0.11.1/graphql/handler/server.go:124 +0xa7 panic(0x9fe620, 0xc0001b8de0) /usr/local/go/src/runtime/panic.go:679 +0x1b2 recommender-survey-archive/cmd/graph/generated.(*executionContext)._Query(0xc0001b8da0, 0xc0c740, 0xc0002c8ff0, 0xc0001b8b40, 0x1, 0x1, 0x40dcc6, 0xc0002c8fc0) /home/simon/go/src/recommender-survey-archive/cmd/graph/generated/generated.go:1527 +0x6b4 recommender-survey-archive/cmd/graph/generated.(*executableSchema).Exec.func1(0xc0c740, 0xc0002c8fc0, 0x10) /home/simon/go/src/recommender-survey-archive/cmd/graph/generated/generated.go:99 +0x7b github.com/99designs/gqlgen/graphql/handler.executor.DispatchOperation.func1.1.1(0xc0c740, 0xc0002c8fc0, 0xc0001b8db0) /home/simon/go/pkg/mod/github.com/99designs/gqlgen@v0.11.1/graphql/handler/executor.go:100 +0x43 github.com/99designs/gqlgen/graphql/handler.newExecutor.func2(0xc0c740, 0xc0002c8fc0, 0xc0001b8db0, 0xbeec60) /home/simon/go/pkg/mod/github.com/99designs/gqlgen@v0.11.1/graphql/handler/executor.go:33 +0x3a github.com/99designs/gqlgen/graphql/handler.executor.DispatchOperation.func1.1(0xc0c740, 0xc0002c8f60, 0xc0002c8690) /home/simon/go/pkg/mod/github.com/99designs/gqlgen@v0.11.1/graphql/handler/executor.go:99 +0x130 github.com/99designs/gqlgen/graphql/handler/transport.POST.Do(0xc0ae40, 0xc0002922a0, 0xc00028e300, 0xc0b300, 0xc0000c0ff0) /home/simon/go/pkg/mod/github.com/99designs/gqlgen@v0.11.1/graphql/handler/transport/http_post.go:52 +0x353 github.com/99designs/gqlgen/graphql/handler.(*Server).ServeHTTP(0xc0000d5e40, 0xc0ae40, 0xc0002922a0, 0xc00028e300) /home/simon/go/pkg/mod/github.com/99designs/gqlgen@v0.11.1/graphql/handler/server.go:140 +0x23c net/http.(*ServeMux).ServeHTTP(0x106d9c0, 0xc0ae40, 0xc0002922a0, 0xc00028e200) /usr/local/go/src/net/http/server.go:2387 +0x1bd net/http.serverHandler.ServeHTTP(0xc0002921c0, 0xc0ae40, 0xc0002922a0, 0xc00028e200) /usr/local/go/src/net/http/server.go:2802 +0xa4 net/http.(*conn).serve(0xc000270b40, 0xc0c680, 0xc000290b00) /usr/local/go/src/net/http/server.go:1890 +0x875 created by net/http.(*Server).Serve /usr/local/go/src/net/http/server.go:2928 +0x384
Gateway:
Encountered error when loading recommender-survey-archive at http://localhost:4004/query: 422: Unprocessable Entity
When the following graphql type is added everything works smoothly
type Workaround @key(fields: "id") {
id: Int
}
Note: @key is required for this workaround
What did you expect?
I don’t understand the details but I would expect gqlgen to add the following Query without the Workaround type, so that the service can be federated:
extend type Query {
_entities(representations: [_Any!]!): [_Entity]!
_service: _Service!
}
Minimal graphql.schema and models to reproduce
See above.
versions
gqlgen version
?
v0.11.1
go version
?
go version go1.13.6 linux/amd64
EDIT: Btw. I want to thank you for providing a go lib that allows to federate with apollo. You have created a really smooth technology that helps me a lot, great job and thank you!
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 16
- Comments: 17
Actually, looks like someone else already submitted a fix, but the PR was closed before it was merged 🤔
The same issue here. any news?
I really would like this also
It is important for me as well to fix this
I have the same issue, I fix it adding this in all my schemas: