Skip to content

v0.6.0

Choose a tag to compare

@yhnavein yhnavein released this 22 Nov 20:45
· 200 commits to master since this release
  • feat: No longer clients generated as classes. They were quite cumbersome and in this version they are replaced by simple objects.
  • feat: Simpler client's usage and support for tree-shaking
  • feat: Allows easily to use axios-extensions or more advanced axios settings
  • breaking change: Removed reactHooks option. It's no longer necessary.
  • breaking change: axios and fetch templates changed to accomodate new method of clients export.

How to migrate:

  • Remove all occurences of useClient hook and import each of clients directly
-import { useClient } from '../../client';
+import { authClient, productClient } from '../../client';
const Component = () => {
-const { authClient, productClient } = useClient();
  • Same goes to each usage of clients or ClientContext

  • Remove all class imports from generated client

-import { AuthClient, ProductClient } from '../../client';
+import { authClient, productClient } from '../../client';
const Component = () => {
-const authClient = new AuthClient();
-const productClient = new ProductClient();
  • Look out for all Interceptors (or other code that reffers to global Axios instance) and replace global Axios instance with the one that is used in generated client.
-import Axios, { AxiosRequestConfig, AxiosError} from 'axios';
+import { AxiosRequestConfig, AxiosError, AxiosInstance } from 'axios';

-export function useAuthInterceptor() {
-  Axios.interceptors.request.use([...]
+export function useAuthInterceptor(axios: AxiosInstance) {
+  axios.interceptors.request.use(

-  Axios.interceptors.response.use(
+  axios.interceptors.response.use(

Axios instance is exposed in the client generated code:

+import { axios } from '../client';

-useAuthInterceptor();
+useAuthInterceptor(axios);