Skip to content

Commit d794c2c

Browse files
Merge pull request #35 from d1g1tinc/fix-default-fetch-policies
Fix ApiProvider#defaultFetchPolicies
2 parents 9d9a71d + 7e152ea commit d794c2c

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/react/context.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export interface ApiProviderProps {
3131
* Sets the default `fetchPolicy` which is used by `useApiQuery`
3232
* if no `fetchPolicy` is provided to the hook.
3333
*/
34-
defaultFetchPolicy?: Partial<ApiRequestFetchPolicy>
34+
defaultFetchPolicies?: Partial<ApiProviderDefaultFetchPolicies>
3535
}
3636

3737
export const ApiProvider: React.FC<ApiProviderProps> = function ApiProvider(
@@ -42,7 +42,9 @@ export const ApiProvider: React.FC<ApiProviderProps> = function ApiProvider(
4242
value={{
4343
api: props.api,
4444
defaultFetchPolicies: {
45-
useApiQuery: props.defaultFetchPolicy || DEFAULT_QUERY_FETCH_POLICY
45+
useApiQuery:
46+
props.defaultFetchPolicies?.useApiQuery ||
47+
DEFAULT_QUERY_FETCH_POLICY
4648
}
4749
}}
4850
>

src/react/use-api-query/index.spec.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,10 @@ describe('cache', () => {
179179
const {waitForNextUpdate} = renderHook(() => useApiQuery(params), {
180180
wrapper: function Wrapper({children}) {
181181
return (
182-
<ApiProvider api={api} defaultFetchPolicy={defaultFetchPolicy}>
182+
<ApiProvider
183+
api={api}
184+
defaultFetchPolicies={{useApiQuery: defaultFetchPolicy}}
185+
>
183186
{children}
184187
</ApiProvider>
185188
)

0 commit comments

Comments
 (0)