Skip to content

Support code files (js, ts) as schema files #1425

Open
@addiebarron

Description

@addiebarron

Is your feature request related to a problem? Please describe.

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, but during development the most up-to-date information about the schema is in those gql tags, not in the schema.graphql file.

Furthermore, in my IDE, clicking through any client-side definitions (e.g. a query name in a query operation) sends me to the generated schema rather than the typescript source, which is what we'd consider the "source of truth". (I recognize this could also be implemented as an IDE feature. I'll make a ticket there as well).

Describe the solution you'd like

Graphql config files should support js/ts files in the schema field. Consumers can parse the graphql from those files as they choose.

Describe alternatives you've considered

The only working alternative now is to search the codebase for the definitions as they appear in Typescript.

Additional context

Some kind of "source map" concept could potentially solve this as well. I wish I could integrate directly with graphql-codegen!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions