Created
September 10, 2015 18:28
-
-
Save KyleAMathews/3c1d97457a45b50677a7 to your computer and use it in GitHub Desktop.
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 Relay from 'react-relay' | |
export default class CreatePostMutation extends Relay.Mutation { | |
static fragments = { | |
viewer: () => Relay.QL` | |
fragment on User { | |
id | |
allPosts(first:10) { | |
edges { | |
node { | |
id | |
} | |
} | |
} | |
} | |
`, | |
}; | |
getMutation() { | |
return Relay.QL`mutation{createPost}`; | |
} | |
getFatQuery() { | |
return Relay.QL` | |
fragment on CreatePostPayload { | |
postEdge | |
viewer { | |
id | |
} | |
} | |
`; | |
} | |
getConfigs() { | |
return [{ | |
type: 'RANGE_ADD', | |
parentName: 'viewer', | |
parentID: this.props.viewer.id, | |
connectionName: 'allPosts', | |
edgeName: 'postEdge', | |
rangeBehaviors: { | |
'': 'append', | |
}, | |
}]; | |
} | |
getVariables() { | |
return { | |
title: this.props.title, | |
body: this.props.body, | |
created_at: this.props.created_at, | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment