1- /* eslint-disable @typescript-eslint/no-unused-expressions */
2-
3- import type { CreateAPIBasicQueryClientOptions } from '@openapi-qraft/react' ;
41import { requestFn } from '@openapi-qraft/react' ;
5- import * as callbacks from '@openapi-qraft/react/callbacks/index ' ;
2+ import { getMutationCache } from '@openapi-qraft/react/callbacks/getMutationCache ' ;
63import { QueryClient } from '@tanstack/react-query' ;
74import {
8- createInternalReactAPIClient as createAPIOperationClient ,
5+ createInternalReactAPIClient ,
6+ createMinimalAPIClient ,
7+ createNoCallbacksAPIClient ,
98 services ,
109} from './fixtures/files-api/index.js' ;
1110
1211const queryClient = new QueryClient ( ) ;
1312
1413// Default callbacks from redocly config should expose getMutationCache for mutation operations.
15- const apiWithDefaultCallbacks = createAPIOperationClient ( services , {
14+ const apiWithDefaultCallbacks = createInternalReactAPIClient ( services , {
1615 queryClient,
1716} ) ;
1817
@@ -21,35 +20,51 @@ apiWithDefaultCallbacks.files.deleteFiles.getMutationCache();
2120apiWithDefaultCallbacks . files . getFileList . getMutationCache ( ) ;
2221
2322// For basic query options, provided callbacks should define the available methods.
24- type MutationCacheOnlyCallbacks = {
25- getMutationCache : typeof callbacks . getMutationCache ;
26- } ;
2723
28- const customBasicQueryCallbacks : MutationCacheOnlyCallbacks = {
29- getMutationCache : callbacks . getMutationCache ,
30- } ;
24+ const apiWithCustomBasicQueryCallbacksExplicit = createInternalReactAPIClient (
25+ services ,
26+ { queryClient } ,
27+ {
28+ getMutationCache,
29+ }
30+ ) ;
3131
32- const basicQueryOptions : CreateAPIBasicQueryClientOptions = { queryClient } ;
32+ apiWithCustomBasicQueryCallbacksExplicit . files . deleteFiles . getMutationCache ( ) ;
3333
34- const apiWithCustomBasicQueryCallbacksExplicit = createAPIOperationClient <
35- typeof services ,
36- MutationCacheOnlyCallbacks
37- > ( services , basicQueryOptions , customBasicQueryCallbacks ) ;
34+ createMinimalAPIClient (
35+ services ,
36+ { queryClient } ,
37+ { getMutationCache }
38+ ) . files . deleteFiles . getMutationCache ( ) ;
3839
39- apiWithCustomBasicQueryCallbacksExplicit . files . deleteFiles . getMutationCache ( ) ;
40+ createNoCallbacksAPIClient (
41+ { queryClient } ,
42+ { getMutationCache }
43+ ) . files . deleteFiles . getMutationCache ( ) ;
4044
4145// getMutationCache should remain unavailable without queryClient.
42- const apiWithoutQueryClient = createAPIOperationClient <
43- typeof services ,
44- MutationCacheOnlyCallbacks
45- > (
46+
47+ createInternalReactAPIClient (
4648 services ,
49+ { requestFn, baseUrl : 'https://example.com' } ,
4750 {
48- requestFn,
49- baseUrl : 'https://example.com' ,
50- } ,
51- customBasicQueryCallbacks
52- ) ;
51+ getMutationCache,
52+ }
53+ )
54+ // @ts -expect-error - getMutationCache requires queryClient in options
55+ . files . deleteFiles . getMutationCache ( ) ;
56+
57+ createMinimalAPIClient (
58+ services ,
59+ { requestFn, baseUrl : 'https://example.com' } ,
60+ { getMutationCache }
61+ )
62+ // @ts -expect-error - getMutationCache requires queryClient in options
63+ . files . deleteFiles . getMutationCache ( ) ;
5364
54- // @ts -expect-error - getMutationCache requires queryClient in options
55- apiWithoutQueryClient . files . deleteFiles . getMutationCache ( ) ;
65+ createNoCallbacksAPIClient (
66+ { requestFn, baseUrl : 'https://example.com' } ,
67+ { getMutationCache }
68+ )
69+ // @ts -expect-error - getMutationCache requires queryClient in options
70+ . files . deleteFiles . getMutationCache ( ) ;
0 commit comments