federation
federation copied to clipboard
_service { sdl } output doesn't contain custom directive arguments
When I make the { _service { sdl } }
query, the output doesn't contain any custom directives arguments. Using printSubgraphSchema
outputs the expected result.
Typedef example:
directive @date(format: String = "") on FIELD_DEFINITION
type Example implements Content @cacheControl(maxAge: 300) {
exampleVar: String @date
}
Service output:
directive @date(format: String = "") on FIELD_DEFINITION
type Example implements Content {
exampleVar: String
}
printSubgraphSchema
output:
directive @date(format: String = "") on FIELD_DEFINITION
type Example implements Content {
exampleVar(format: String): String
}
Using version: "@apollo/subgraph": "2.0.0-preview.8"
I'm using rover fed2 supergraph compose
to generate the supergraph SDL and this quick fix solved my issue.
const { printSubgraphSchema } = require('@apollo/subgraph');
const resolvers = {
Query: {
_service: (_parent, _args, _context, info) => ({ sdl: printSubgraphSchema(info.schema) }),
}
}
type _Service {
sdl: String
}
type Query {
_service: _Service
}
bad news: we're likely removing printSubgraphSchema
in #1554
good news: this is fixed in #1554
unsettling news: we have tests for this, so i don't know why it isn't working. but it's very unlikely to be broken in the same way: #1554 handles all subgraph schema manipulation in the AST, which is considerably less invasive and prone to this kind of thing.
This still seems to be an issue, I'm not seen the deprecated directive in the schema.
I'm not seen the deprecated directive in the schema
The @deprecated
directive is special, it's a graphQL built-in, and valid graphQL implementation should know of its existence even if it's not part of the schema. Which is why it's not printed. If this create a problem for some schema consumers, then I'd be curious to understand why it would, but a priori this would be more of a bug of that consumer given the graphQL spec. In any case, it's not a "custom" directive so wouldn't part of this issue.
As for this issue, it should be fixed now (nor have we removed printSubgraphSchema
after all), so going to close this.
I get that's a built-in, interesting that's not working on my end. I'll try to see if I find something.
@pcmanus it working for individual subgraphs directly, seem that there is an issue with the gateway, because it might be getting lost when the schema is printed to sdl and consumed by the federation gateway. Opening the subgraph directly the deprecated warning is there, but not working going to the supergraph endpoint
@harbolaez I'm the author of the issue. At the time I was using gateway/subgraph 2.0.5 and I applied my first comment fix which solved that issue.
I no longer work on that project, so I don't know if it works for the most recent versions.