graphql / graphql/graphiql

[lsp-server] Support JS/TS files as schema files

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

Description

_I left a related issue on the graphql-config repository: https://github.com/kamilkisiela/graphql-config/issues/1425_

## Current Behavior (if applicable)

I work on a project that defines its GraphQL schema in `gql` tags across a number of `.ts` files in the server directory. We generate a `schema.graphql` file from those code files in the pre-commit step using [graphql-codegen](https://the-guild.dev/graphql/codegen/docs/config-reference/schema-field#code-files), but during development the most up-to-date information about the schema is in those `gql` tags, not in the `schema.graphql` file.

In VSCode, clicking through any client-side definitions (e.g. command-clicking a query name in an operation) sends me to the generated schema rather than the typescript (which is what we'd consider the "source of truth").

## Desired Behavior

If JS/TS files are passed to the graphql-config `schema` field, VSCode should construct a schema from the `gql` tags in those files and use that as the source of truth.

This could be accomplished using the [`CodeFileLoader`](https://the-guild.dev/graphql/tools/docs/schema-loading#codefileloader) included in `graphql-tools`.

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.