Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_service { sdl } output doesn't contain custom directive arguments #1666

Closed
rubnogueira opened this issue Apr 1, 2022 · 7 comments
Closed

Comments

@rubnogueira
Copy link

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"

@rubnogueira
Copy link
Author

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
}

@queerviolet
Copy link
Contributor

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.

@harbolaez
Copy link

This still seems to be an issue, I'm not seen the deprecated directive in the schema.

@pcmanus
Copy link
Contributor

pcmanus commented Oct 6, 2022

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.

@pcmanus pcmanus closed this as completed Oct 6, 2022
@harbolaez
Copy link

harbolaez commented Oct 6, 2022

I get that's a built-in, interesting that's not working on my end. I'll try to see if I find something.

@harbolaez
Copy link

@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

@rubnogueira
Copy link
Author

rubnogueira commented Oct 6, 2022

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants