Skip to content

Commit

Permalink
Add workaround for bug that causes query skip parameter to be ignor…
Browse files Browse the repository at this point in the history
…ed when `client.resetStore()` is called
  • Loading branch information
glassblowerscat committed Sep 20, 2020
1 parent 435e9a1 commit 37b519b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/components/files/FileActions/FileVersions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,15 @@ export const FileVersions: FC<FileVersionsProps> = (props) => {
const classes = useStyles();

const id = file?.id ?? '';
const shouldSkipQuery = !file;
const { data, loading } = useFileVersionsQuery({
variables: { id },
skip: !file,
// Workaround for a known bug in Apollo client that causes
// `skip` to suddenly be ignored when `client.resetStore` is
// called:
// https://github.com/apollographql/react-apollo/issues/3492#issuecomment-622573677
fetchPolicy: shouldSkipQuery ? 'cache-only' : 'cache-first',
skip: shouldSkipQuery,
});

const total = data?.file.children.total;
Expand Down
8 changes: 7 additions & 1 deletion src/scenes/Projects/Files/ProjectFilesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,17 @@ const ProjectFilesListWrapped: FC = () => {

const isNotRootDirectory = directoryId !== rootDirectoryId;

const shouldSkipQuery = !directoryId;
const { data, loading, error } = useProjectDirectoryQuery({
variables: {
id: directoryId,
},
skip: !directoryId,
// Workaround for a known bug in Apollo client that causes
// `skip` to suddenly be ignored when `client.resetStore` is
// called:
// https://github.com/apollographql/react-apollo/issues/3492#issuecomment-622573677
fetchPolicy: shouldSkipQuery ? 'cache-only' : 'cache-first',
skip: shouldSkipQuery,
});

const parents = data?.directory.parents;
Expand Down

0 comments on commit 37b519b

Please sign in to comment.