graphql / graphql/graphiql

[Question] [language server] implied fragments and support for imports

Open
#1,966 7 comments 1 reaction 0 assignees View on GitHub
lsp-server
Dominant language
TypeScript
Stars
16.9k
Forks
1.9k
Avg merge
22h 45m
Merged PRs (30d)
70

Description

In my GraphQL build system that I set up (built on top of [graphql-code-generator](https://github.com/dotansimha/graphql-code-generator) and [@graphql-tools/import](https://www.npmjs.com/package/@graphql-tools/import)) I require explicit fragment imports:
```
# import SomeFragment from "./some-path.graphql"

query MyQuery {
someField { ...SomeFragment }
}
```

I do this in order to minimize the potential for fragment name conflicts and make it easier to share fragments across packages.

**However, this language server seems to assume that all fragments are globally available which is not always the case. Is there a way to configure this?** If not, would you accept a contribution to make this configurable?

I'm also curious to learn how others deal with sharing fragments across packages. Is using explicit imports good practice? Or is it better to make all fragments globally available and then be careful to make all fragment names unique across the codebase?

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.