github unnoq/orpc v0.37.0

latest releases: v1.8.7, v1.8.6, v1.8.5...
7 months ago

🚨 Breaking Changes 🚨

.infiniteOptions input now accepts a function

.infiniteOptions input now requires a function, giving you more control over where the cursor is placed and improves compatibility by removing the requirement for your input to match { cursor?: any }.

const listQuery = useInfiniteQuery(
  orpc.planet.list.infiniteOptions({
    input: cursor => ({ cursor }),
    getNextPageParam: lastPage => (lastPage.at(-1)?.id ?? -1) + 1,
    initialPageParam: 0,
  }),
)

🌟 .spec Helper 🌟

The .spec helper allows you to customize OpenAPI specs based on middlewares and error handling.

Example: Adding security via middleware

import { oo } from '@orpc/openapi'

const authMid = oo.spec(
  os.middleware(({ context, path, next }, input) => {
    // Authentication logic
    return next()
  }),
  {
    security: [{ bearerAuth: [] }],
  },
)

Example: Attaching OpenAPI metadata to errors

const base = os.errors({
  UNAUTHORIZED: oo.spec({}, {
    security: [{ bearerAuth: [] }],
  }),
})

Any procedure using authMid or derived from base will automatically include the security field in the OpenAPI spec.

   🚨 Breaking Changes

  • query: Redesign pageParam input to use a function and refine internal types  -  by @unnoq in #126 (172fe)

   🚀 Features

   🏎 Performance

  • server: Use empty body for undefined RPC input/output  -  by @unnoq in #128 (854b6)
    View changes on GitHub

Don't miss a new orpc release

NewReleases is sending notifications on new releases.