otahontas / trpc-rtk-query

Automatically generate RTK Query api endpoints from your tRPC setup
MIT License
36 stars 6 forks source link

Version and api updates #214

Closed otahontas closed 8 months ago

otahontas commented 8 months ago

This PR removes the createApi option from this library. I find it easier to just support one way of generating the hooks, so from now on api initialising should be done as follows:

import { createApi } from "@reduxjs/toolkit/query/react";
import { enhanceApi } from "trpc-rtk-query";

// Use function provided by rtk to create your api
const rtkApi = createApi({
  baseQuery: fetchBaseQuery({ baseUrl: "/" }),
  endpoints: () => ({}),
})

// Enhance the api with hooks
export const api = enhanceApi({
  client,
  api: rtkApi
})

Basically users need to always pass in an existing api instance created with redux toolkit. I've added a createEmptyApi (happy to take suggestions for a better name :D) helper that generates api instance without any endpoints that can be passed then to enhanceApi function.

Bumping also redux toolkit major and pushing this library towards 0.1.0.

changeset-bot[bot] commented 8 months ago

🦋 Changeset detected

Latest commit: cea9e18187231a7892468db111bb8b4d4191c621

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | -------------- | ----- | | trpc-rtk-query | Minor |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR