graphql / graphql/graphql-spec

Directives at the top of a SDL file

Open
#410 5 comments 11 reactions 0 assignees View on GitHub
👻 Needs Champion 💤 stale ? 💭 Strawman (RFC 0)
Dominant language
JavaScript
Stars
14.6k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

In the latest [Working Group meeting](https://github.com/graphql/graphql-wg/blob/master/notes/2018-02-01.md) Graphcool presented [GraphQL Import](https://github.com/graphcool/graphql-import). It was brought up that we could change the syntax to be based on directives instead of comments:

```graphql
@import(defs: [Post, Comment] from: "./other-types.graphql")
```

instead of

```graphql
# import Post, Comment from "./other-types.graphql"
```

In the current spec, directives must always be placed after another node. As such, there is no way to place a directive at the top of a file. I volunteered to create an RFC to rectify this using the `@import` directive as motivation.

Discussion in the issue for [graphql-import](https://github.com/graphcool/graphql-import/issues/89#issuecomment-368077528) let to the conclusion that import should not switch to a directive based syntax.

I still think it might be valuable to allow directives in the beginning of a file and would love to hear other use cases for this before proceeding with an RFC.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.