RTK Query's API and architecture is oriented around declaring API endpoints up front. This lends itself well to automatically generating API slice definitions from external API schema definitions, such as OpenAPI and GraphQL.
We have early previews of code generation capabilities available as separate tools.
We have a first version of a code generator from OpenAPI schemas over at
You can create an api by running:
We recommend placing these generated types in one file that you do not modify (so you can constantly re-generate it when your API definition changes) and creating a second file to enhance it with additional info:
There is a very early WIP PR that implements code generation based on a GraphQL spec, and an open issue on the GraphQL Generator repo asking if an RTK Query generator would be potentially useful.