You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At The Guild, we’ve decided to work as much as possible in public; that’s why we are opening the roadmaps for all of our projects.
The goals for this are:
So you will know what we are working on, what we see as a higher priority, and know what to expect from our projects in the future
So you can share your opinions and thoughts about what we do and influence our decisions
So you can join us and contribute to our efforts!
Before laying down the roadmap of GraphQL Code Generator v3, we would like to thank all of you for being so many who use codegen daily and for contributing to making it such a complete project! 🚀
While some people judge that GraphQL is difficult, GraphQL Code Generator v3 aims to change that perspective by providing a unified configuration along with a smaller and simpler generated code.
By providing a unified package and configuration for all client-side use cases, all existing and future plugin alternatives will be moved to community repos.
Let’s now cover these changes in detail.
A unified configuration and package for all GraphQL clients
Most of the existing client-side plugins (typescript-react-apollo, typescript-react-query, etc) rely on the generation of hooks or SDKs that wrap the underlying GraphQL Client in a type-safe way.
However, the generation of hooks or SDK code brings many downsides:
an unnecessary increase of the final bundle size
misalignment between the generated hooks signature and the underlying GraphQL Client
inconsistencies of configuration options and preset compatibility across packages (ex: near-operation-file compatibility)
To make GraphQL code generation great and simple, the v3 version will introduce two major changes:
a new unique preset for all GraphQL clients, which include better developer experience, smaller bundle size, stronger typings, and easier-to-follow best practices
a TypeScript-first configuration file that will allow configuration autocompletion
Here is how you can already configure codegen for all GraphQL Clients:
First, start GraphQL Code Generator in watch mode:
yarn graphql-codegen --watch
Using GraphQL Code Generator will type your GraphQL Query and Mutations as you write them ⚡️
Now, each query or mutation written with the generated graphql() function will be automatically typed!
For example, with Apollo Client (React):
importReactfrom'react';import{useQuery}from'@apollo/client';import{graphql}from'./gql/gql';importFilmfrom'./Film';// here, `allFilmsWithVariablesQueryDocument` is fully typed!constallFilmsWithVariablesQueryDocument=graphql(/* GraphQL */` query allFilmsWithVariablesQuery($first: Int!) { allFilms(first: $first) { edges { node { ...FilmItem } } } }`);functionApp(){// Most GraphQL Clients know how to deal with typed GraphQL documents,// providing typed data and typed variablesconst{ data }=useQuery(allFilmsWithVariablesQueryDocument,{variables: {first: 10}});return(<divclassName="App">{data &&<ul>{data.allFilms?.edges?.map((e,i)=>e?.node&&<Filmfilm={e?.node}key={`film-${i}`}/>)}</ul>}</div>);}exportdefaultApp;
Thanks to work made to integrate TypeDocumentNode (the underlying plugin used by preset: client) with most of the popular GraphQL clients, you no longer need hooks or SDK, simple GraphQL documents works!
We believe that the preset: client approach is the way to get the best of TypeScript and GraphQL by:
reducing the size of the generated bundle
only the graphql() function needs to be imported (no type, hooks, document imports)
removing layers between your application and your chosen GraphQL Client
providing stronger typings that will stay aligned with your chosen GraphQL Client
We aim for GraphQL Code Generator 3.0’s client preset to become the official way to generate GraphQL Types for front-end use cases, replacing all existing hook and SDK-based plugins.
For this reason, we encourage you to already give a try at the codegen v3 client preset (@graphql-codegen/client-presec) and provide feedback on this issue.
The v3 stable release will be shipped once sufficient feedback is posted.
Finally, while the GraphQL Code Generator 3.0 milestone aims to provide a unified front-end experience through the preset: client, the 3.x versions aim to fully rewrite the core packages of codegen.
Some core parts of codegen are more than 6 years old and need to be rewritten (optimized, simplified, and more).
We plan to incorporate the pending issues related to the core packages in this gradual 3.x milestones.
Introduction of the “community plugins”
Historically, all plugins were pushed to the https://github.com/dotansimha/graphql-code-generator repository, making it hard for us to review all contributions in a reasonable timeframe and to enforce consistency across all the options introduced in the different packages.
We believe that the best way to keep codegen extensible and improve the contribution experience at scale is to introduce the concept of community plugins.
A community plugin offers a feature-set that diverges from the preset: client or a plugin created by the community.
Soon, all the existing plugins part of the list below and all the future plugins created by the community will live in their dedicated repository:
@graphql-codegen/typescript-react-apollo
@graphql-codegen/typescript-graphql-request
@graphql-codegen/typescript-apollo-angular
@graphql-codegen/typescript-apollo-client-helpers
@graphql-codegen/typescript-react-query
@graphql-codegen/typescript-urql
@graphql-codegen/named-operations-object
@graphql-codegen/urql-introspection
@graphql-codegen/flow-resolvers
@graphql-codegen/typescript-vue-apollo
@graphql-codegen/typescript-rtk-query
@graphql-codegen/flow-operations
@graphql-codegen/typescript-msw
@graphql-codegen/typescript-mongodb
@graphql-codegen/typescript-type-graphql
@graphql-codegen/jsdoc
@graphql-codegen/typescript-vue-urql
@graphql-codegen/kotlin
@graphql-codegen/typescript-vue-apollo-smart-ops
@graphql-codegen/java
@graphql-codegen/c-sharp-operations
@graphql-codegen/hasura-allow-list
@graphql-codegen/typescript-stencil-apollo
@graphql-codegen/relay-operation-optimizer
@graphql-codegen/typescript-oclif
@graphql-codegen/java-resolvers
@graphql-codegen/java-apollo-android
All the above plugins will be eligible for repository ownership transfer based on relevant past contributions.
Of course, such a change will come with help from our side:
We will create a new “Create a plugin” guide that will provide complete information and guidelines (ex: publishing, codegen APIs, adding your plugin to the codegen hub)
Since each community plugin will live in its own repository, we will provide a proper Github repository template with building and publishing CI tools configured.
What about server-side plugins?
The 3.x milestones include some work on server-side plugins such as typescript-resolvers (ex: improving Federation support).
Milestones
Below are the details of the aforementioned plans for the 3.0 and 3.x milestones.
Create a TypedDocumentNode string alternative (TypedString) that does not require GraphQL AST on the Client (should be easily configurable within the preset)
shareable configs? → (one codegen file versus many)
Improve TypeScript support in libraries that already support TypedDocumentNode (variables should be required if there are required variables in the operation declaration and optional if there are none)
URQL
Apollo Client
Back-end code generation issues
We will go over the following typescript-resolvers and graphql-modules pending plugins issues:
At The Guild, we’ve decided to work as much as possible in public; that’s why we are opening the roadmaps for all of our projects.
The goals for this are:
Before laying down the roadmap of GraphQL Code Generator v3, we would like to thank all of you for being so many who use codegen daily and for contributing to making it such a complete project! 🚀
While some people judge that GraphQL is difficult, GraphQL Code Generator v3 aims to change that perspective by providing a unified configuration along with a smaller and simpler generated code.
By providing a unified package and configuration for all client-side use cases, all existing and future plugin alternatives will be moved to community repos.
Let’s now cover these changes in detail.
A unified configuration and package for all GraphQL clients
Most of the existing client-side plugins (
typescript-react-apollo
,typescript-react-query
, etc) rely on the generation of hooks or SDKs that wrap the underlying GraphQL Client in a type-safe way.However, the generation of hooks or SDK code brings many downsides:
near-operation-file
compatibility)To make GraphQL code generation great and simple, the v3 version will introduce two major changes:
Here is how you can already configure codegen for all GraphQL Clients:
The
client
preset comes with a simple opinionated configuration and a lightweight types-only generation.To try the new
client
preset, please install the following dependencies:First, start GraphQL Code Generator in watch mode:
Using GraphQL Code Generator will type your GraphQL Query and Mutations as you write them ⚡️
Now, each query or mutation written with the generated
graphql()
function will be automatically typed!For example, with Apollo Client (React):
Thanks to work made to integrate
TypeDocumentNode
(the underlying plugin used bypreset: client
) with most of the popular GraphQL clients, you no longer need hooks or SDK, simple GraphQL documents works!We believe that the
preset: client
approach is the way to get the best of TypeScript and GraphQL by:graphql()
function needs to be imported (no type, hooks, document imports)Finally, this new
preset: client
has been properly tested on all popular GraphQL clients across most frameworks:@apollo/client
(since3.2.0
, not when using React Components (<Query>
))@urql/core
(since1.15.0
)@urql/preact
(since1.4.0
)urql
(since1.11.0
)graphql-request
(since5.0.0
)react-query
(with[email protected]
)swr
(with[email protected]
)@urql/exchange-graphcache
(since3.1.11
)@urql/svelte
(since1.1.3
)@vue/apollo-composable
(since4.0.0-alpha.13
)villus
(since1.0.0-beta.8
)@urql/vue
(since1.11.0
)graphql-js
(since15.2.0
)graphql-request
(since5.0.0
)You will find demos and code examples for each of them in the
examples/front-end/
folder of the codegen repository.You will also find a complete guide for React and Vue in codegen documentation.
We aim for GraphQL Code Generator 3.0’s client preset to become the official way to generate GraphQL Types for front-end use cases, replacing all existing hook and SDK-based plugins.
For this reason, we encourage you to already give a try at the codegen v3
client
preset (@graphql-codegen/client-presec
) and provide feedback on this issue.The v3 stable release will be shipped once sufficient feedback is posted.
Finally, while the GraphQL Code Generator
3.0
milestone aims to provide a unified front-end experience through thepreset: client
, the3.x
versions aim to fully rewrite the core packages of codegen.Some core parts of codegen are more than 6 years old and need to be rewritten (optimized, simplified, and more).
We plan to incorporate the pending issues related to the core packages in this gradual
3.x
milestones.Introduction of the “community plugins”
Historically, all plugins were pushed to the https://github.com/dotansimha/graphql-code-generator repository, making it hard for us to review all contributions in a reasonable timeframe and to enforce consistency across all the options introduced in the different packages.
We believe that the best way to keep codegen extensible and improve the contribution experience at scale is to introduce the concept of community plugins.
Soon, all the existing plugins part of the list below and all the future plugins created by the community will live in their dedicated repository:
@graphql-codegen/typescript-react-apollo
@graphql-codegen/typescript-graphql-request
@graphql-codegen/typescript-apollo-angular
@graphql-codegen/typescript-apollo-client-helpers
@graphql-codegen/typescript-react-query
@graphql-codegen/typescript-urql
@graphql-codegen/named-operations-object
@graphql-codegen/urql-introspection
@graphql-codegen/flow-resolvers
@graphql-codegen/typescript-vue-apollo
@graphql-codegen/typescript-rtk-query
@graphql-codegen/flow-operations
@graphql-codegen/typescript-msw
@graphql-codegen/typescript-mongodb
@graphql-codegen/typescript-type-graphql
@graphql-codegen/jsdoc
@graphql-codegen/typescript-vue-urql
@graphql-codegen/kotlin
@graphql-codegen/typescript-vue-apollo-smart-ops
@graphql-codegen/java
@graphql-codegen/c-sharp-operations
@graphql-codegen/hasura-allow-list
@graphql-codegen/typescript-stencil-apollo
@graphql-codegen/relay-operation-optimizer
@graphql-codegen/typescript-oclif
@graphql-codegen/java-resolvers
@graphql-codegen/java-apollo-android
All the above plugins will be eligible for repository ownership transfer based on relevant past contributions.
Of course, such a change will come with help from our side:
What about server-side plugins?
The
3.x
milestones include some work on server-side plugins such astypescript-resolvers
(ex: improving Federation support).Milestones
Below are the details of the aforementioned plans for the
3.0
and3.x
milestones.3.0
client
presetgraphql-request
https://github.com/prisma-labs/graphql-request/pull/350/filesgraphql-request
)graphql-request
)gql-tag-operation-preset
gql-tag-operations-preset
babelPlugin
doesn't work withvite
#8206documents
preset preconfigurationgql-tag-operations-preset
in favor of theclient-preset
preset: front-end
#8184graphql-request
docs on their repo4.x
5.x
preset: client
improvements→ feat: override operation field types via directives #8071
preset: client
to not use the old plugins (get rid of actual core packages)apollo-angular
docsgraphql-scalars
#8413Future of codegen CLI
config
) → WIP 🚧DetailedError
which is not well-handled bylistr
#8200graphql
dependencyBack-end code generation issues
We will go over the following
typescript-resolvers
andgraphql-modules
pending plugins issues:Resolvers
#5517The text was updated successfully, but these errors were encountered: