-
Notifications
You must be signed in to change notification settings - Fork 79
/
moveFilesMutation.js
40 lines (36 loc) · 1.07 KB
/
moveFilesMutation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { graphql } from '@apollo/client/react/hoc';
import gql from 'graphql-tag';
import { fileInterface, file } from 'lib/fileFragments';
const mutation = gql`
mutation MoveFiles($folderId:ID!, $fileIds:[ID]!) {
moveFiles(folderId: $folderId, fileIds: $fileIds) {
...FileInterfaceFields
...FileFields
}
}
${fileInterface}
${file}
`;
const config = {
props: ({ mutate, ownProps: { actions = {} } }) => ({
actions: Object.assign({}, actions, {
files: Object.assign({}, actions.files, {
moveFiles: (folderId, fileIds) => mutate({
variables: {
folderId,
fileIds,
},
update: () => {
// todo:
// Refactor this once Apollo GraphQL adds support
// for invalidating specific queries in the cache.
// Context: https://github.com/silverstripe/silverstripe-asset-admin/issues/809
window.ss.apolloClient.resetStore();
}
}),
}),
}),
}),
};
export { mutation, config };
export default graphql(mutation, config);