Including unused directives in schema? #1972
-
We have a schema that's about to be federated, but the second subgraph is not included yet. I generate the subgraph schemas using Apollo's This has two issues for me, one directly related to graphql kotlin (I think) and one that might be more general graphql. The issue I think is directly related to graphql-kotlin is that the subgraphs here don't include unused directives, if I just add my directive to a single property it's included in the subgraph but otherwise it's not. Can I force it to be included? Can I generate the subgraph some other way to make include it? The issue that seems more general graphql, possibly, is that if I add a dummy property with the annotation (which is applicable to FIELD_DEFINITION and QUERY), the supergraph only shows it being applicable to QUERY and not FIELD_DEFINITION. In addition, it's removed from all field defs where it was in the subgraph. But there are built-in directives that have FIELD_DEFINITION as a location, so it doesn't seem to be illegal? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hello 👋
Starting with the v7
This sounds like a question more about Apollo Federation behavior than this lib. As you know directives fall into two categories -> executable directives (user specifies them in a query) and schema directives (defined on schema elements). AFAIK supergraph composition will automatically preserve executable directives (as long as their definitions match across all subgraphs that define them) BUT you need to explicitly opt-in to preserve schema directives through |
Beta Was this translation helpful? Give feedback.
AFAIK we (Apollo) don't preserve those custom schema directives in the API schemas (i.e. schemas that clients interact with). You can preserve them in the supergraph schema through
@composeDirective
but I believe they will be stripped out from API schema.