This file contains hidden or 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
| const CreatePageViewerQuery = graphql` | |
| query CreatePageViewerQuery { | |
| viewer { | |
| id | |
| } | |
| } | |
| ` |
This file contains hidden or 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
| _handlePost = (viewerId) => { | |
| const {description, imageUrl} = this.state | |
| CreatePostMutation(description, imageUrl, viewerId, () => this.props.router.replace('/')) | |
| } |
This file contains hidden or 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
| import { withRouter } from 'react-router' | |
| import CreatePostMutation from './CreatePostMutation' | |
| import { QueryRenderer, graphql } from 'react-relay' | |
| import environment from './Environment' |
This file contains hidden or 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
| export default withRouter(CreatePage) |
This file contains hidden or 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
| import { | |
| commitMutation, | |
| graphql, | |
| } from 'react-relay' | |
| import {ConnectionHandler} from 'relay-runtime' | |
| import environment from './Environment' | |
| | |
| const mutation = graphql` | |
| mutation DeletePostMutation($input: DeletePostInput!) { | |
| deletePost(input: $input) { |
This file contains hidden or 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
| _handleDelete = () => { | |
| DeletePostMutation(this.props.post.id, null) | |
| } |
This file contains hidden or 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
| import DeletePostMutation from './DeletePostMutation' |
This file contains hidden or 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
| updater: (proxyStore) => { | |
| const deletePostField = proxyStore.getRootField('deletePost') | |
| const deletedId = deletePostField.getValue('deletedId') | |
| const viewerProxy = proxyStore.get(viewerId) | |
| const connection = ConnectionHandler.getConnection(viewerProxy, 'ListPage_allPosts') | |
| if (connection) { | |
| ConnectionHandler.deleteNode(connection, deletedId) | |
| } | |
| }, | |
| optimisticUpdater: (proxyStore) => { |
This file contains hidden or 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
| export default createFragmentContainer(Post, graphql` | |
| fragment Post_viewer on Viewer { | |
| id | |
| } | |
| fragment Post_post on Post { | |
| id | |
| description | |
| imageUrl | |
| } | |
| `) |
This file contains hidden or 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
| _handleDelete = () => { | |
| DeletePostMutation(this.props.post.id, this.props.viewer.id) | |
| } |