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

RFC: Provide codemods to/from GraphQL Code Generator’s client-preset [Strawman] #95

Open
kitten opened this issue Mar 1, 2024 · 4 comments
Labels
future 🔮 An enhancement or feature proposal that will be addressed after the next release

Comments

@kitten
Copy link
Member

kitten commented Mar 1, 2024

Important

This is a strawman RFC.
It's a very early thought that has come up, but documenting it is crucial to transparently communicate what we've got planned.

Summary

Currently, the two most common ways of writing GraphQL, which we'd like to target are:

While we expect people to migrate from different patterns, these two are the most important to us. The client-preset is the next similar (and next newest) alternative to gql.tada and hence lends itself to an automatic migration. The graphql-tag library is still the most popular way of authoring GraphQL documents and is the most popular (as far as we know).

Note

A prior version of this RFC mentioned migrating from gql.tada back to client-preset. However with #160 being scheduled, we won't need a reverse codemod any longer. Reverting any migration patterns is deprioritised, since #160 turns gql.tada into a hybrid-alternative that can also function similarly to the client-preset.

Proposed Solution

Following are sections (TBD) that define the patterns we'd like to recognise and what to convert them to.

Requirements

TODO/TBD

  • The codemods should be runnable via the CLI: RFC: Implement a CLI for programmatic TS LSP & Checking tasks #76
    • “Ejecting” should be a separate command that should deactivate and replace gql.tada and put new tooling necessary for client-preset in place
    • Migrating from client-preset should be suggested when running an init command, if it's installed
    • Uninstalling/Removing dependencies should be suggested as a next step
@kitten kitten added the future 🔮 An enhancement or feature proposal that will be addressed after the next release label Mar 1, 2024
@kitten kitten changed the title RFC: Provide codemods to/from GraphQL Code Generator’s client-preset RFC: Provide codemods to/from GraphQL Code Generator’s client-preset [Strawman] Mar 1, 2024
@nandorojo
Copy link

This RFC is timely for us. I've grown tired of our codegen times with client preset. I'd love to use gql.tada if it's an option, especially if it's possible to bail out. That said, I can't imagine using it incrementally. We'd need to migrate everything over so our fragments etc aren't lost.

We'll be watching this closely.

@kitten
Copy link
Member Author

kitten commented Mar 25, 2024

Updated the RFC to reflect that we don't have to prioritise gql.tada -> client-preset (i.e. a reverse codemod) any longer, given that #160 should cover the concerns that may force users off of gql.tada after they've migrated.

I further added graphql-tag to the list of desired codemods though, since this is still a common target for migration.

I'll add some samples of what and how code should be converted soon ™️

@nandorojo
Copy link

Interesting, so it would offer a watch script similar to graphql-codegen's and that would cache the types so that TS doesn't have to check those, right? Good to know.

@nandorojo
Copy link

Is a migration from client-preset → gql.tada still feeling likely here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
future 🔮 An enhancement or feature proposal that will be addressed after the next release
Projects
None yet
Development

No branches or pull requests

2 participants