graphql / graphql/graphql-spec
Scope for operation and fragment names
- Dominant language
- JavaScript
- Stars
- 14.6k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
First of all, I understand what this spec calls a document and that a document is a request containing operations and fragments.
But tools also use "projects" (say, a set of documents with reusable fragments) and currently there is a problem in the way they do it. I think the way to make it better is having something on the spec specifying how to work with projects.
Let me detail the problem:
There are tools like generators (apollo and graphql-code-generator) and extensions (Apollo GraphQL for VSCode).
When you have these tools in your project, they consider that every file containing graphql operations and fragments are in a single scope. That is problematic because developer then need to use unique prefixes for names.
One may want to use per-component names (and hence, duplicate across whole project) but that is not possible.
In an analogy with sass, it have `:local` scope so one can define things only for that specific file.
So I suggest that the spec specify something that allows names to be public (over the project) or local (file scope).
Contributor guide
Assessment
This issue has not been assessed yet.