Skip to content

Instantly share code, notes, and snippets.

const CreatePageViewerQuery = graphql`
query CreatePageViewerQuery {
viewer {
id
}
}
`
_handlePost = (viewerId) => {
const {description, imageUrl} = this.state
CreatePostMutation(description, imageUrl, viewerId, () => this.props.router.replace('/'))
}
import { withRouter } from 'react-router'
import CreatePostMutation from './CreatePostMutation'
import { QueryRenderer, graphql } from 'react-relay'
import environment from './Environment'
export default withRouter(CreatePage)
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) {
_handleDelete = () => {
DeletePostMutation(this.props.post.id, null)
}
import DeletePostMutation from './DeletePostMutation'
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) => {
export default createFragmentContainer(Post, graphql`
fragment Post_viewer on Viewer {
id
}
fragment Post_post on Post {
id
description
imageUrl
}
`)
_handleDelete = () => {
DeletePostMutation(this.props.post.id, this.props.viewer.id)
}