Skip to content

Commit fa53f8f

Browse files
authored
fix(typescript-react-apollo): loosen defaultBaseOptions type (#464)
* fix(typescript-react-apollo): loosen defaultBaseOptions type * Add some named properties
1 parent ba7e551 commit fa53f8f

3 files changed

Lines changed: 22 additions & 4 deletions

File tree

.changeset/happy-keys-kiss.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-codegen/typescript-react-apollo': patch
3+
---
4+
5+
fix: loosen defaultBaseOptions type

packages/plugins/typescript/react-apollo/src/config.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,21 @@ export interface ReactApolloRawPluginConfig extends RawClientSideBasePluginConfi
266266
* ```
267267
*/
268268
addDocBlocks?: boolean;
269-
270-
defaultBaseOptions?: { [key: string]: string };
269+
/**
270+
* @description Configure default mutation and query hook options.
271+
*/
272+
defaultBaseOptions?: ReactApolloPluginConfigDefaultBaseOptions;
271273

272274
hooksSuffix?: string;
273275
}
276+
277+
export interface ReactApolloPluginConfigDefaultBaseOptions {
278+
awaitRefetchQueries?: boolean;
279+
errorPolicy?: string;
280+
fetchPolicy?: string;
281+
ignoreResults?: boolean;
282+
notifyOnNetworkStatusChange?: boolean;
283+
returnPartialData?: boolean;
284+
ssr?: boolean;
285+
[key: string]: any;
286+
}

packages/plugins/typescript/react-apollo/src/visitor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
LoadedFragment,
1111
OMIT_TYPE,
1212
} from '@graphql-codegen/visitor-plugin-common';
13-
import { ReactApolloRawPluginConfig } from './config.js';
13+
import { ReactApolloPluginConfigDefaultBaseOptions, ReactApolloRawPluginConfig } from './config.js';
1414

1515
const APOLLO_CLIENT_3_UNIFIED_PACKAGE = `@apollo/client`;
1616
const GROUPED_APOLLO_CLIENT_3_IDENTIFIER = 'Apollo';
@@ -31,7 +31,7 @@ export interface ReactApolloPluginConfig extends ClientSideBasePluginConfig {
3131
withResultType: boolean;
3232
withMutationOptionsType: boolean;
3333
addDocBlocks: boolean;
34-
defaultBaseOptions: { [key: string]: string };
34+
defaultBaseOptions: ReactApolloPluginConfigDefaultBaseOptions;
3535
hooksSuffix: string;
3636
}
3737

0 commit comments

Comments
 (0)