apollographql / apollographql/federation

printSubgraphSchema removes description from custom directives

Open
#2,147 0 comments 0 reactions 0 assignees View on GitHub
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
![image](https://user-images.githubusercontent.com/112618115/191273418-7fcb93ce-bf32-4cd0-a015-b50bfa9678ea.png)
printSchemaWithDirectives and printSubgraphSchema
![image](https://user-images.githubusercontent.com/112618115/191273513-f74ebdea-3efa-4e69-8590-09ad4775778e.png)

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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.