Support include's in graphql files.
- 主要语言
- Go
- 星标
- 10.8k
- 派生
- 1.3k
- 平均合并
- 2 天 36 分钟
- 30 天内合并 PR
- 26
描述
We use the `schema:` directive of gqlgen.yml extensively to load shared types and directives. In fact we've used it so extensively that we now have an entire dependency tree. Example:
shared_directive.graphql:
```
directive @product(
name: String!
) on ENUM_VALUE
```
shared_type.graphql:
```
enum FeedbackType {
ANSWER,
COMMENT @product(name: "myproduct")
}
```
gqlgen.yml:
```
schema:
- shared_directive.graphql
- shared_type.graphql
- schema.graphql
````
We only use `@product` in shared_type.graphql, not in schema.graphql; we need to remember to add shared_directive.graphql in gqlgen.yml even though gqlgen.yml does not use shared_directive.graphql directly. This is brittle and hard for devs to fiagure out what actually needs to be included in the `schema:` directive.
**The ask**: Add support for an `#include` directive in .graphql files. (Or `#gqlgen_include`, or whatever name makes sense.) This is a comment to most graphql parsers, but gqlgen reads it specially and uses it as an alternate way of loading a schema, as if it had been suggested in schema.graphql. The include is relative to the directory where the `#include` is found. Then we could do this:
```
--- shared_type.graphql:
#include "shared_directive.graphql" # for @product
enum FeedbackType {
ANSWER,
COMMENT @product(name: "myproduct")
}
--- gqlgen.yml:
schema:
- shared_type.graphql
- schema.graphql
````
贡献指南
评估
这个 Issue 还没有评估数据。