Skip to content

Instantly share code, notes, and snippets.

@ryardley
Created October 28, 2018 06:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryardley/17da8e6a19b9ab7043c7fda77d42d609 to your computer and use it in GitHub Desktop.
Save ryardley/17da8e6a19b9ab7043c7fda77d42d609 to your computer and use it in GitHub Desktop.
const Comments = ({ repoFullName }) => (
<Mutation mutation={DELETE_COMMENT}>
{(deleteComment) => (
<Query query={GET_CURRENT_USER}>
{({data: {currentUser}}) => (
<Subscription
subscription={COMMENTS_SUBSCRIPTION}
variables={{ repoFullName }}>
{({ data: { commentAdded }, loading }) => (
<div>
<h3>Hi {currentUser.name}</h3>
<h4>New comment: {!loading && commentAdded.content}</h4>
<Button onClick={() => deleteComment({variables: {commentId:commentAdded.id}})}>Delete Comment</Button>
</div>
)}
</Subscription>
)}
</Query>
)}
</Mutation>
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment