Last active
August 25, 2017 15:06
-
-
Save gc-codesnippets/f4b4ad9687a4016ee93bfcb36a8fa63a to your computer and use it in GitHub Desktop.
This file contains 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 class ChangeTodoStatusMutation extends Relay.Mutation { | |
static fragments = { | |
todo: () => Relay.QL` | |
fragment on Todo { | |
id, | |
complete | |
} | |
`, | |
viewer: () => Relay.QL` | |
fragment on Viewer { | |
id, | |
} | |
`, | |
} | |
| |
getMutation () { | |
return Relay.QL`mutation{updateTodo}` | |
} | |
| |
getFatQuery () { | |
return Relay.QL` | |
fragment on UpdateTodoPayload { | |
todo { | |
complete, | |
}, | |
viewer { | |
allTodoes, | |
}, | |
} | |
` | |
} | |
| |
getConfigs () { | |
return [{ | |
type: 'FIELDS_CHANGE', | |
fieldIDs: { | |
todo: this.props.todo.id, | |
viewer: this.props.viewer.id, | |
}, | |
}] | |
} | |
| |
getVariables () { | |
return { | |
complete: this.props.complete, | |
id: this.props.todo.id, | |
} | |
} | |
| |
getOptimisticResponse () { | |
var viewerPayload = {id: this.props.viewer.id} | |
return { | |
todo: { | |
complete: this.props.complete, | |
id: this.props.todo.id, | |
}, | |
viewer: viewerPayload, | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment