Skip to content

Commit

Permalink
fix: queryOptions with custom Error type
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnvanhulle committed Jan 3, 2025
1 parent 2ea0e2d commit fba76b6
Show file tree
Hide file tree
Showing 134 changed files with 1,257 additions and 707 deletions.
88 changes: 22 additions & 66 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"files": [
"README.md"
],
"files": ["README.md"],
"imageSize": 100,
"commit": false,
"commitConvention": "angular",
Expand All @@ -11,189 +9,147 @@
"name": "Stijn Van Hulle",
"avatar_url": "https://avatars.githubusercontent.com/u/5904681?v=4",
"profile": "http://www.stijnvanhulle.be",
"contributions": [
"code"
]
"contributions": ["code"]
},
{
"login": "xPhentom",
"name": "Wouter Roozeleer",
"avatar_url": "https://avatars.githubusercontent.com/u/5096867?v=4",
"profile": "https://fosstodon.org/@xphentom",
"contributions": [
"code"
]
"contributions": ["code"]
},
{
"login": "b6pzeusbc54tvhw5jgpyw8pwz2x6gs",
"name": "Alfred",
"avatar_url": "https://avatars.githubusercontent.com/u/15520015?v=4",
"profile": "https://aluc.io/",
"contributions": [
"code"
]
"contributions": ["code"]
},
{
"login": "raveclassic",
"name": "Kirill Agalakov",
"avatar_url": "https://avatars.githubusercontent.com/u/1743568?v=4",
"profile": "https://github.com/raveclassic",
"contributions": [
"code"
]
"contributions": ["code"]
},
{
"login": "WickyNilliams",
"name": "Nick Williams",
"avatar_url": "https://avatars.githubusercontent.com/u/1091390?v=4",
"profile": "http://wicky.nillia.ms",
"contributions": [
"doc"
]
"contributions": ["doc"]
},
{
"login": "helt",
"name": "helt",
"avatar_url": "https://avatars.githubusercontent.com/u/1732112?v=4",
"profile": "https://github.com/helt",
"contributions": [
"code"
]
"contributions": ["code"]
},
{
"login": "Ti-webdev",
"name": "Vasily Mikhaylovsky",
"avatar_url": "https://avatars.githubusercontent.com/u/478565?v=4",
"profile": "https://github.com/Ti-webdev",
"contributions": [
"code"
]
"contributions": ["code"]
},
{
"login": "chiptus",
"name": "Chaim Lev-Ari",
"avatar_url": "https://avatars.githubusercontent.com/u/1381655?v=4",
"profile": "https://github.com/chiptus",
"contributions": [
"code"
]
"contributions": ["code"]
},
{
"login": "pafnuty",
"name": "Pavel Belousov",
"avatar_url": "https://avatars.githubusercontent.com/u/1635679?v=4",
"profile": "http://projects.pafnuty.name",
"contributions": [
"code"
]
"contributions": ["code"]
},
{
"login": "dmitry-blackwave",
"name": "Dmitry Belov",
"avatar_url": "https://avatars.githubusercontent.com/u/5526543?v=4",
"profile": "https://github.com/dmitry-blackwave",
"contributions": [
"code"
]
"contributions": ["code"]
},
{
"login": "aburgel",
"name": "Alex Burgel",
"avatar_url": "https://avatars.githubusercontent.com/u/341478?v=4",
"profile": "https://github.com/aburgel",
"contributions": [
"code"
]
"contributions": ["code"]
},
{
"login": "dgarciamuria",
"name": "Daniel Garcia",
"avatar_url": "https://avatars.githubusercontent.com/u/8144333?v=4",
"profile": "https://github.com/dgarciamuria",
"contributions": [
"code"
]
"contributions": ["code"]
},
{
"login": "wuyuanyi135",
"name": "wuyuanyi135",
"avatar_url": "https://avatars.githubusercontent.com/u/11760870?v=4",
"profile": "https://github.com/wuyuanyi135",
"contributions": [
"code"
]
"contributions": ["code"]
},
{
"login": "cjthompson",
"name": "Chris Thompson",
"avatar_url": "https://avatars.githubusercontent.com/u/1958266?v=4",
"profile": "https://github.com/cjthompson",
"contributions": [
"code"
]
"contributions": ["code"]
},
{
"login": "hkang1",
"name": "Caleb Hoyoul Kang",
"avatar_url": "https://avatars.githubusercontent.com/u/220971?v=4",
"profile": "https://github.com/hkang1",
"contributions": [
"code"
]
"contributions": ["code"]
},
{
"login": "grreeenn",
"name": "Gregory Zhukovsky",
"avatar_url": "https://avatars.githubusercontent.com/u/13204857?v=4",
"profile": "https://github.com/grreeenn",
"contributions": [
"code"
]
"contributions": ["code"]
},
{
"login": "ChilloManiac",
"name": "Christoffer Nørbjerg",
"avatar_url": "https://avatars.githubusercontent.com/u/3761964?v=4",
"profile": "https://github.com/ChilloManiac",
"contributions": [
"code"
]
"contributions": ["code"]
},
{
"login": "CHE1RON",
"name": "CHE1RON",
"avatar_url": "https://avatars.githubusercontent.com/u/122524301?v=4",
"profile": "https://codefy.de/de/karriere",
"contributions": [
"code"
]
"contributions": ["code"]
},
{
"login": "ekaradon",
"name": "ekaradon",
"avatar_url": "https://avatars.githubusercontent.com/u/9439390?v=4",
"profile": "https://github.com/ekaradon",
"contributions": [
"code"
]
"contributions": ["code"]
},
{
"login": "Thijmen",
"name": "Thijmen Stavenuiter",
"avatar_url": "https://avatars.githubusercontent.com/u/383903?v=4",
"profile": "https://thijmen.dev",
"contributions": [
"code"
]
"contributions": ["code"]
},
{
"login": "bohdanhusak",
"name": "Bohdan Husak",
"avatar_url": "https://avatars.githubusercontent.com/u/13829370?v=4",
"profile": "https://github.com/bohdanhusak",
"contributions": [
"doc"
]
"contributions": ["doc"]
}
],
"contributorsPerLine": 7,
Expand Down
8 changes: 8 additions & 0 deletions .changeset/soft-planes-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@kubb/plugin-svelte-query": patch
"@kubb/plugin-react-query": patch
"@kubb/plugin-solid-query": patch
"@kubb/plugin-vue-query": patch
---

queryOptions with custom Error type
6 changes: 6 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ title: Changelog

# Changelog

## 3.3.5
- [`plugin-react-query`](/plugins/plugin-react-query/): queryOptions with custom Error type
- [`plugin-svelte-query`](/plugins/plugin-svelte-query/): queryOptions with custom Error type
- [`plugin-vue-query`](/plugins/plugin-vue-query/): queryOptions with custom Error type
- [`plugin-solid-query`](/plugins/plugin-solid-query/): queryOptions with custom Error type

## 3.3.4
- [`plugin-ts`](/plugins/plugin-ts): minLength, maxLength, pattern as part of the jsdocs
- [`plugin-client`](/plugins/plugin-client): baseURL could be undefined, do not throw error if that is the case
Expand Down
8 changes: 4 additions & 4 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
"serve": "vitepress serve"
},
"dependencies": {
"@shikijs/vitepress-twoslash": "^1.24.2",
"@shikijs/vitepress-twoslash": "^1.26.1",
"mermaid": "^11.4.1",
"sitemap": "^8.0.0",
"vitepress": "^1.5.0",
"vitepress-plugin-group-icons": "^1.3.1",
"vitepress-plugin-group-icons": "^1.3.2",
"vue": "^3.5.13"
},
"devDependencies": {
Expand All @@ -44,12 +44,12 @@
"@kubb/plugin-zod": "workspace:*",
"@kubb/react": "workspace:*",
"@mermaid-js/mermaid-cli": "^11.4.2",
"@types/node": "^20.17.10",
"@types/node": "^20.17.11",
"@types/react": "catalog:",
"cross-env": "^7.0.3",
"react": "catalog:",
"unplugin-kubb": "workspace:^",
"vite": "^6.0.3"
"vite": "^6.0.7"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
12 changes: 6 additions & 6 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@
"@kubb/plugin-ts": "workspace:*",
"@kubb/plugin-zod": "workspace:*",
"@kubb/react": "workspace:*",
"@tanstack/react-query": "^5.62.7",
"@tanstack/solid-query": "^5.62.7",
"@tanstack/svelte-query": "^5.62.7",
"@tanstack/vue-query": "^5.62.7",
"@tanstack/react-query": "^5.62.12",
"@tanstack/solid-query": "^5.62.12",
"@tanstack/svelte-query": "^5.62.12",
"@tanstack/vue-query": "^5.62.12",
"axios": "^1.7.9",
"msw": "^2.6.9",
"msw": "^2.7.0",
"react": "catalog:",
"solid-js": "^1.9.3",
"svelte": "^3.59.2",
"swr": "^2.2.5",
"swr": "^2.3.0",
"tsup": "catalog:",
"vue": "^3.5.13",
"zod": "^3.24.1"
Expand Down
16 changes: 8 additions & 8 deletions examples/advanced/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@
"@kubb/plugin-ts": "workspace:*",
"@kubb/plugin-zod": "workspace:*",
"@kubb/react": "workspace:*",
"@tanstack/query-core": "^5.62.7",
"@tanstack/react-query": "^5.62.7",
"@tanstack/solid-query": "^5.62.7",
"@tanstack/svelte-query": "^5.62.7",
"@tanstack/vue-query": "^5.62.7",
"@types/react": "^19.0.1",
"@tanstack/query-core": "^5.62.12",
"@tanstack/react-query": "^5.62.12",
"@tanstack/solid-query": "^5.62.12",
"@tanstack/svelte-query": "^5.62.12",
"@tanstack/vue-query": "^5.62.12",
"@types/react": "^19.0.2",
"axios": "^1.7.9",
"msw": "^2.6.9",
"msw": "^2.7.0",
"react": "^19.0.0",
"solid-js": "^1.9.3",
"svelte": "^3.59.2",
"swr": "^2.2.5",
"swr": "^2.3.0",
"vue": "^3.5.13",
"zod": "^3.24.1"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async function findPetsByStatus({ step_id }: { step_id: FindPetsByStatusPathPara

export function findPetsByStatusQueryOptions({ step_id }: { step_id: FindPetsByStatusPathParams['step_id'] }, config: Partial<RequestConfig> = {}) {
const queryKey = findPetsByStatusQueryKey({ step_id })
return queryOptions({
return queryOptions<ResponseConfig<FindPetsByStatusQueryResponse>, FindPetsByStatus400, ResponseConfig<FindPetsByStatusQueryResponse>, typeof queryKey>({
enabled: !!step_id,
queryKey,
queryFn: async ({ signal }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function findPetsByTagsQueryOptions(
config: Partial<RequestConfig> = {},
) {
const queryKey = findPetsByTagsQueryKey(params)
return queryOptions({
return queryOptions<ResponseConfig<FindPetsByTagsQueryResponse>, FindPetsByTags400, ResponseConfig<FindPetsByTagsQueryResponse>, typeof queryKey>({
queryKey,
queryFn: async ({ signal }) => {
config.signal = signal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ export function findPetsByTagsInfiniteQueryOptions(
config: Partial<RequestConfig> = {},
) {
const queryKey = findPetsByTagsInfiniteQueryKey(params)
return infiniteQueryOptions({
return infiniteQueryOptions<
ResponseConfig<FindPetsByTagsQueryResponse>,
FindPetsByTags400,
ResponseConfig<FindPetsByTagsQueryResponse>,
typeof queryKey,
number
>({
queryKey,
queryFn: async ({ signal, pageParam }) => {
config.signal = signal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async function getPetById({ petId }: { petId: GetPetByIdPathParams['petId'] }, c

export function getPetByIdQueryOptions({ petId }: { petId: GetPetByIdPathParams['petId'] }, config: Partial<RequestConfig> = {}) {
const queryKey = getPetByIdQueryKey({ petId })
return queryOptions({
return queryOptions<ResponseConfig<GetPetByIdQueryResponse>, GetPetById400 | GetPetById404, ResponseConfig<GetPetByIdQueryResponse>, typeof queryKey>({
enabled: !!petId,
queryKey,
queryFn: async ({ signal }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ async function getUserByName({ username }: { username: GetUserByNamePathParams['

export function getUserByNameQueryOptions({ username }: { username: GetUserByNamePathParams['username'] }, config: Partial<RequestConfig> = {}) {
const queryKey = getUserByNameQueryKey({ username })
return queryOptions({
return queryOptions<
ResponseConfig<GetUserByNameQueryResponse>,
GetUserByName400 | GetUserByName404,
ResponseConfig<GetUserByNameQueryResponse>,
typeof queryKey
>({
enabled: !!username,
queryKey,
queryFn: async ({ signal }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async function loginUser({ params }: { params?: LoginUserQueryParams }, config:

export function loginUserQueryOptions({ params }: { params?: LoginUserQueryParams }, config: Partial<RequestConfig> = {}) {
const queryKey = loginUserQueryKey(params)
return queryOptions({
return queryOptions<ResponseConfig<LoginUserQueryResponse>, LoginUser400, ResponseConfig<LoginUserQueryResponse>, typeof queryKey>({
queryKey,
queryFn: async ({ signal }) => {
config.signal = signal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async function logoutUser(config: Partial<RequestConfig> = {}) {

export function logoutUserQueryOptions(config: Partial<RequestConfig> = {}) {
const queryKey = logoutUserQueryKey()
return queryOptions({
return queryOptions<ResponseConfig<LogoutUserQueryResponse>, Error, ResponseConfig<LogoutUserQueryResponse>, typeof queryKey>({
queryKey,
queryFn: async ({ signal }) => {
config.signal = signal
Expand Down
Loading

0 comments on commit fba76b6

Please sign in to comment.