-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Merge pull request #1176 from creative-commoners/pulls/5/refactor-gra…
…phql3 ENH Refactor Element and graphql hoc
Showing
11 changed files
with
82 additions
and
292 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,9 @@ | ||
import { graphql } from '@apollo/client/react/hoc'; | ||
import gql from 'graphql-tag'; | ||
import { config as readBlocksConfig, query as readBlocksQuery } from './readBlocksForAreaQuery'; | ||
|
||
// GraphQL query for saving a specific block | ||
const mutation = gql` | ||
export const publishBlockMutation = gql` | ||
mutation PublishBlock($blockId:ID!) { | ||
publishBlock(id: $blockId) { | ||
id | ||
} | ||
} | ||
`; | ||
|
||
const config = { | ||
props: ({ mutate, ownProps: { actions } }) => { | ||
const handlePublishBlock = (blockId) => mutate({ | ||
variables: { | ||
blockId | ||
}, | ||
}); | ||
|
||
return { | ||
actions: { | ||
...actions, | ||
handlePublishBlock, | ||
}, | ||
}; | ||
}, | ||
options: ({ areaId }) => ({ | ||
// Refetch versions after mutation is completed | ||
refetchQueries: [{ | ||
query: readBlocksQuery, | ||
variables: readBlocksConfig.options({ areaId }).variables | ||
}] | ||
}), | ||
}; | ||
|
||
export { mutation, config }; | ||
|
||
export default graphql(mutation, config); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters