Skip to content

Commit b6a8cb8

Browse files
committed
feat(file-input): add ability to set fetchPolicy via the props
1 parent a0b2d49 commit b6a8cb8

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

packages/file-input/src/FileInput.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const FileInput: React.ComponentType<FileInputProps> = withApollo(
2323
maxFiles: 1,
2424
value: null,
2525
sessionCache: false,
26+
fetchPolicy: 'network-only',
2627
};
2728

2829
public static getDerivedStateFromProps(props: FileInputProps, state: FileInputState) {
@@ -59,7 +60,7 @@ const FileInput: React.ComponentType<FileInputProps> = withApollo(
5960
let response = null;
6061

6162
try {
62-
response = await client.query({ query: FILE_UPLOAD_INFO_QUERY, fetchPolicy: 'network-only' });
63+
response = await client.query({ query: FILE_UPLOAD_INFO_QUERY, fetchPolicy: this.props.fetchPolicy });
6364
} catch (e) {
6465
this.setState({ error: e });
6566

packages/file-input/src/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { FetchPolicy } from 'apollo-client';
2+
13
export type FileValue = {
24
fileId: string;
35
filename: string;
@@ -19,6 +21,7 @@ export type FileInputProps = {
1921
error: object | null;
2022
}) => React.ReactNode;
2123
public?: boolean;
24+
fetchPolicy?: FetchPolicy;
2225
maxFiles?: number;
2326
sessionCache?: boolean;
2427
onUploadDone?: (value: FileInputValue, originalFile?: OriginalFileInputValue) => Promise<FileInputValue>;

0 commit comments

Comments
 (0)