Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support .gts & .gjs file loading on graphql-tag-pluck #6519

Open
DeclanBoller opened this issue Sep 16, 2024 · 0 comments
Open

Support .gts & .gjs file loading on graphql-tag-pluck #6519

DeclanBoller opened this issue Sep 16, 2024 · 0 comments

Comments

@DeclanBoller
Copy link
Contributor

DeclanBoller commented Sep 16, 2024

Is your feature request related to a problem? Please describe.
Currently, the graphql-tag-pluck package (and other tools relying on it, such as graphql-codegen) does not support loading GraphQL documents from files using Ember's .gts and .gjs file extensions. These file formats are introduced in Ember's First-Class Component Templates RFC, and are becoming more widely adopted in the Ember.js ecosystem.

Without support for these file extensions, developers working in Ember.js are forced to work around the problem by either duplicating GraphQL documents in separate .ts files or restructuring their code, which disrupts the natural workflow within Ember.js projects. This creates unnecessary friction, as GraphQL documents cannot be conveniently co-located with component logic when using these newer file formats.

Describe the solution you'd like
I would like graphql-tag-pluck to support plucking GraphQL documents from .gts and .gjs files, just as it does for .ts and .js files. This would enable developers working with Ember's first-class component templates to keep their GraphQL queries and mutations co-located with their component logic.

Describe alternatives you've considered

The primary alternative is to define GraphQL documents in separate .ts files and import them into .gts or .gjs files. While this works, it is inconvenient and reduces the benefits of co-locating code. For example:

  • It disrupts the modular structure that Ember encourages, where component templates, logic, and queries can be defined together in the same file.
  • It forces developers to maintain two separate files (one for the query and one for the component logic), increasing the potential for errors and reducing code clarity.
ardatan pushed a commit that referenced this issue Oct 15, 2024
] (#6521)

* tests: add test cases for gts and gjs files

* feat: support gts and gjs files

* chore: add changeset

* refactor/chore: glimmer package not required, just use @glimmer/syntax

* chore: remove comment

* refactor: make gts & gjs tests reflect glimmer components more accurately

* refactor: use embroider-build/content-tag instead of @glimmer/syntax

* fix: lint errors

* chore: why is prettier being difficult

* chore: add comment about `gjs` file parsing

* refactor: make code more succinct and remove redundant comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant