import gql from 'graphql-tag' import { graphql, compose } from 'react-apollo' const GetCommit = gql` query GetCommit($owner: String, $repo: String, $sha: String) { getCommit(owner: $owner, repo: $repo, sha: $sha) { sha url html_url author { name email date } committer { name email date } tree { url sha } message parents { sha url } } }` const PostCommit = gql` mutation PostCommit($commitForm: CommitFormInput! , $owner: String, $repo: String) { postCommit(commitForm: $commitForm, owner: $owner, repo: $repo) { sha url author { name email date } committer { name email date } message tree { url sha } parents { url sha } } }` const withAppSyncCommit = compose( graphql(GetCommit, { name: 'getCommit', options: (ownProps) => ({ fetchPolicy: 'cache-and-network', variables: { owner: ownProps.owner, repo: ownProps.repo, sha: ownProps.sha } }), props: (props) => { if (props.getCommit.error) console.log(props.getCommit.error) return props } }) ) export { GetCommit, PostCommit, withAppSyncCommit }