Empty `type Query {\n}` in the sdl response
See original GitHub issueI encountered this issue when Apollo-Gateway has trouble recognizing sdl from a graphql service served from federation-jvm. The schema is copied from Apollo-Gateway sample for the inventory service, with a little modification by removing the extend
keyword in the front and adding @extends
directive:
type Product @key(fields: "upc") @extends {
upc: String! @external
weight: Int @external
price: Int @external
shippingEstimate: Int @requires(fields: "price weight")
}
This schema works well in the NodeJs version of graphql federation. However, with the same schema copied to the side of federation-jvm, Apollo-Gateway stopped to recognize the schema. The following message showed in the Apollo-Gateway log:
Encountered error when loading productsExt at http://localhost:9000/graphql: Syntax Error: Expected Name, found }
Looking at the response body of sdl query from federation-jvm, the @extends was pulled in front of @keyword and there is an empty type Query {\n}
.
{
"data": {
"_service": {
"sdl": "type Product @extends @key(fields : \"upc\") {\n price: Int @external\n shippingEstimate: Int @requires(fields : \"price weight\")\n upc: String! @external\n weight: Int @external\n}\n\ntype Query {\n}\n"
}
}
}
The order of the @extends
directive seemed to have no negative effect, as verified in by switching the order of @extends
and @keyword
in the NodeJS graphql federation. The empty type Query {}
is probably the cause.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:7
To work around this issue, you can include the trivial
type Query
in your schema so that it is not empty, for example:@yuhanz In the meanwhile, we’ve copied their printer and patched it, so if you use
federation-jvm
v0.3.4 or later you shouldn’t have any issues (note that using v0.3.4 requires upgrading tographql-java
v13).I’ll close out this issue, but let me know if you still experience similar issues and I can reopen.