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
rtk-query-codegen-openapi: If tag is specified and tags exist in a schema, they are now mapped to providesTags or invalidatesTags. (#2071)
* If tags are specified, they are now mapped to providesTags or invalidatesTags.
* npm run format
* npm run test --updateSnapshot
* addTagTypes
* Exported addTagTypes so that the list of addTagTypes can be referenced from outside.
* The tagging function has been made optional.
* add tag test
* code style & method naming
* docs
* addTagTypes does not support injectEndpoints, so it has been moved to enhanceEndpoints.
* Fixed a mistake where providesTags and invalidatesTags were written in the wrong place.
Co-authored-by: Lenz Weber <lenz.weber@mayflower.de>
Copy file name to clipboardExpand all lines: docs/rtk-query/usage/code-generation.mdx
+10Lines changed: 10 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -62,6 +62,15 @@ and then call the code generator:
62
62
npx @rtk-query/codegen-openapi openapi-config.ts
63
63
```
64
64
65
+
#### Generating tags
66
+
67
+
If your OpenAPI specification uses [tags](https://swagger.io/docs/specification/grouping-operations-with-tags/), you can specify the `tag` option to the codegen.
68
+
That will result in all generated endpoints having `providesTags`/`invalidatesTags` declarations for the `tags` of their respective operation definition.
69
+
70
+
Note that this will only result in string tags with no ids, so it might lead to scenarios where too much is invalidated and unneccessary requests are made on mutation.
71
+
72
+
In that case it is still recommended to manually specify tags by using [`enhanceEndpoints`](./code-splitting.mdx) on top of the generated api and manually declare `providesTags`/`invalidatesTags`.
0 commit comments