Skip to content

Commit 4a828bb

Browse files
authored
Merge pull request #50 from 8base/feat(file-input)-set-fetchPolicy-to-network-only
feat(file-input): add ability to set fetchPolicy via the props
2 parents 1ee1d86 + 9b68006 commit 4a828bb

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

packages/file-input/src/FileInput.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const FileInput: React.ComponentType<FileInputProps> = withApollo(
5959
let response = null;
6060

6161
try {
62-
response = await client.query({ query: FILE_UPLOAD_INFO_QUERY });
62+
response = await client.query({ query: FILE_UPLOAD_INFO_QUERY, fetchPolicy: this.props.fetchPolicy });
6363
} catch (e) {
6464
this.setState({ error: e });
6565

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>;

packages/file-input/test/__tests__/__snapshots__/index.test.tsx.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
exports[`should call onChange when file is uploaded for input with custom on upload handler 1`] = `
44
Array [
55
Object {
6+
"fetchPolicy": undefined,
67
"query": Object {
78
"definitions": Array [
89
Object {
@@ -93,6 +94,7 @@ Array [
9394
exports[`should call onChange when file is uploaded for multiple files input 1`] = `
9495
Array [
9596
Object {
97+
"fetchPolicy": undefined,
9698
"query": Object {
9799
"definitions": Array [
98100
Object {
@@ -183,6 +185,7 @@ Array [
183185
exports[`should call onChange when file is uploaded for single file input 1`] = `
184186
Array [
185187
Object {
188+
"fetchPolicy": undefined,
186189
"query": Object {
187190
"definitions": Array [
188191
Object {
@@ -273,6 +276,7 @@ Array [
273276
exports[`should call onChange when file is uploaded for single file input with public modifier 1`] = `
274277
Array [
275278
Object {
279+
"fetchPolicy": undefined,
276280
"query": Object {
277281
"definitions": Array [
278282
Object {

0 commit comments

Comments
 (0)