silverstripe-cms/client/src/state/history/rollbackPageMutation.js
Guy Sartorelli ddbe4ea4ce
DEP Upgrade build stack (#2795)
* DEP Upgrade webpack config and various deps

* DEP Update code to work with upgraded libraries

* MNT run yarn build
2022-12-19 10:20:52 +13:00

42 lines
763 B
JavaScript

import { graphql } from '@apollo/client/react/hoc';
import gql from 'graphql-tag';
const mutation = gql`
mutation rollbackPage($id:ID!, $toVersion:Int!) {
rollbackPage(
id: $id
toVersion: $toVersion
) {
id
}
}
`;
const config = {
props: ({ mutate, ownProps: { actions } }) => {
const rollbackPage = (id, toVersion) => mutate({
variables: {
id,
toVersion,
},
});
return {
actions: {
...actions,
rollbackPage,
// For BC:
revertToVersion: rollbackPage,
},
};
},
options: {
// Refetch versions after mutation is completed
refetchQueries: ['ReadHistoryViewerPage']
}
};
export { mutation, config };
export default graphql(mutation, config);