Skip to content

Commit 5c5a970

Browse files
authored
Merge pull request #341 from OpenAPI-Qraft/feat/1.x/new-tanstack-for-legacy-client
chore(1.x): update `peerDependency` ⛱︎ require `@tanstack/react-query@^5.80.0` due to interface changes
2 parents 12f5656 + 827403e commit 5c5a970

File tree

15 files changed

+81
-27
lines changed

15 files changed

+81
-27
lines changed

.changeset/kind-words-wonder.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@openapi-qraft/tanstack-query-react-types': minor
3+
'@openapi-qraft/react': minor
4+
---
5+
6+
Update `peerDependency` to `@tanstack/react-query@^5.80.0` due to breaking changes in the `UseSuspenseInfiniteQueryOptions` interface.

.changeset/rare-lobsters-clean.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@openapi-qraft/openapi-typescript-plugin": patch
3+
"@openapi-qraft/plugin": patch
4+
---
5+
6+
Added Commander to "peerDependencies" where required.

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
push:
88
branches:
99
- main
10+
- versions/1.x
1011

1112
jobs:
1213
validate:

.github/workflows/e2e.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
push:
88
branches:
99
- main
10+
- versions/1.x
1011

1112
jobs:
1213
e2e:

e2e/projects/typescript-nodenext-nodenext/src/index.ts

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ import * as callbacks from '@openapi-qraft/react/callbacks/index';
22
import { useMutation } from '@openapi-qraft/react/callbacks/useMutation';
33
import { useQuery } from '@openapi-qraft/react/callbacks/useQuery';
44
import {
5-
QraftSecureRequestFn,
65
createSecureRequestFn,
6+
QraftSecureRequestFn,
77
} from '@openapi-qraft/react/Unstable_QraftSecureRequestFn';
8-
98
import {
10-
createAPIClient as createAPIClientMjs,
119
components,
10+
createAPIClient as createAPIClientMjs,
1211
paths,
1312
} from './api/index.js';
1413

@@ -60,3 +59,39 @@ if (typeof QraftSecureRequestFn !== 'undefined') {
6059
console.error('QraftSecureRequestFn is not imported from esm project.');
6160
process.exit(1);
6261
}
62+
63+
function useTsCheck() {
64+
const client = createAPIClientMjs();
65+
66+
const query = client.pet.findPetsByStatus.useSuspenseInfiniteQuery(
67+
{},
68+
{
69+
initialPageParam: {
70+
query: {
71+
status: 'sold',
72+
},
73+
},
74+
getNextPageParam: (lastPage, allPages, lastPageParam, allPageParams) => {
75+
// @ts-expect-error - should not be never or any
76+
lastPageParam.query?.status satisfies never;
77+
lastPageParam.query?.status satisfies
78+
| undefined
79+
| 'sold'
80+
| 'available'
81+
| 'pending';
82+
83+
return lastPageParam.query?.status === 'sold'
84+
? {
85+
query: {
86+
status: 'sold',
87+
},
88+
}
89+
: undefined;
90+
},
91+
}
92+
);
93+
94+
query.data.pages[0] satisfies typeof client.pet.findPetsByStatus.types.data;
95+
// @ts-expect-error - should not be never or any
96+
query.data.pages[0] satisfies never;
97+
}

packages/openapi-typescript-plugin/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
"openapi-typescript": "^7.3.0",
3131
"typescript": "^5.3.3"
3232
},
33+
"peerDependencies": {
34+
"commander": "^11.1.0"
35+
},
3336
"devDependencies": {
3437
"@openapi-qraft/eslint-config": "workspace:*",
3538
"@openapi-qraft/test-fixtures": "workspace:*",

packages/plugin/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@
2727
"dependencies": {
2828
"ansi-colors": "^4.1.3",
2929
"camelcase": "^8.0.0",
30-
"commander": "^11.1.0",
3130
"micromatch": "^4.0.5",
3231
"openapi-typescript": "^7.3.0",
3332
"ora": "^8.0.1",
3433
"yaml": "^2.3.4"
3534
},
35+
"peerDependencies": {
36+
"commander": "^11.1.0"
37+
},
3638
"devDependencies": {
3739
"@openapi-qraft/test-fixtures": "workspace:*",
3840
"@types/micromatch": "^4",

packages/react-client/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"@openapi-qraft/openapi-typescript-plugin": "workspace:^",
2121
"@openapi-qraft/rollup-config": "workspace:*",
2222
"@openapi-qraft/test-fixtures": "workspace:*",
23-
"@tanstack/react-query": "^5.17.3",
23+
"@tanstack/react-query": "^5.80.6",
2424
"@testing-library/jest-dom": "^5.17.0",
2525
"@testing-library/react": "^13.4.0",
2626
"@testing-library/user-event": "^14.5.2",
@@ -39,9 +39,8 @@
3939
"vitest": "^1.4.0"
4040
},
4141
"peerDependencies": {
42-
"@tanstack/query-core": "^5.0.0",
43-
"@tanstack/react-query": "^5.0.0",
44-
"react": "^18.0.0"
42+
"@tanstack/query-core": "^5.80.0",
43+
"@tanstack/react-query": "^5.80.0"
4544
},
4645
"files": [
4746
"dist",

packages/react-client/src/callbacks/useSuspenseQueries.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const useSuspenseQueries: (
3030
return useSuspenseQueriesTanstack(
3131
{
3232
...options,
33+
// @ts-expect-error - New version of @tanstack/react-query accepts queryFn as a symbol
3334
queries: options.queries.map((queryOptions) => {
3435
const optionsWithQueryKey =
3536
'parameters' in queryOptions

packages/react-client/src/lib/callQueryClientMethodWithQueryFilters.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export function callQueryClientMethodWithQueryFilters<
2525
// @ts-expect-error - Too complex to type
2626
return queryClient[queryFilterMethod](
2727
composeQueryFilters(schema, filters as never),
28-
// @ts-expect-error - Argument types are too complex
2928
...args.slice(1, -1)
3029
);
3130
}

0 commit comments

Comments
 (0)