Last active
August 16, 2016 01:12
-
-
Save jbaxleyiii/1a99254d8966646c67aae038692da757 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
//components/TodoApp.js | |
import { graphql } from 'react-apollo' | |
class TodoApp extends React.Component { | |
render () { ... } | |
} | |
const withTodos = graphql(todosQuery, { | |
props({ loading, data }) { | |
return { todos: data ? data.todos : [] }; | |
} | |
}); | |
const withAddTodo = graphql(addTodoMutation, { | |
props: ({ mutate }) => ({ | |
addTodo: (text) => mutate({ variables: { text } }); | |
}) | |
}); | |
const withToggleTodo = graphql(toggleTodoMutation, { | |
props: ({ mutate }) => ({ | |
toggleTodo: (id, complete) => mutate({ variables: { id, complete } }); | |
}) | |
}); | |
export default withTodos(withAddTodo(withToggleTodo(TodoApp))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment