apollographql / apollographql/federation
printSubgraphSchema removes description from custom directives
- Dominant language
- TypeScript
- Stars
- 725
- Forks
- 276
- Avg merge
- 1h 47m
- Merged PRs (30d)
- 1
Description
I am currently using a custom directive (hbtAuth) that uses mapSchema to also add comment descriptions which are used to enrich the supergraph documentation. To export the whole subgraph schema including these comments to a singular file I want to use the printSubgraphSchema but then the descriptions disappear.
A workaround to this problem is with the @graphql-tools/utils package to first print the schema with printSchemaWithDirectives and then convert it again to a GraphQLSchema and use printSubgraphSchema. Because printSchemaWithDirectives will add the comments to the types and fields and printSubgraphSchema wont removed those comments.
Only printSubgraphSchema

printSchemaWithDirectives and printSubgraphSchema

The reason why I don't use printSchemaWithDirectives is because then the federation directives and scalars are also printed and then composeAndValidate fails because the @tag directive has more "on" entrees.
Versions:
@graphql-tools/schema 9.0.3
@apollo/subgraph 2.1.1
@apollo/federation 0.36.1
Contributor guide
Research direction
Start by comparing printSubgraphSchema with printSchemaWithDirectives, using the reported custom directive and descriptions as the reproduction case. Check how composeAndValidate handles the resulting schema, and consider the behavior complete when printSubgraphSchema preserves custom descriptions without including federation directives or scalars that break composition.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100