Skip to content

Instantly share code, notes, and snippets.

{
"schemaPath": "schema.graphql",
"extensions": {
"endpoints": {
"prod": {
"url": "https://api.graph.cool/simple/v1/swapi",
"subscription": {
"url": "wss://subscriptions.graph.cool/simple/v1/swapi"
}
},
import Relay from 'react-relay'
// ...
export default Relay.createContainer(TodoList, {
fragments: {
viewer: () => Relay.QL`
fragment on Viewer {
allTodoes(last: 1000) {
edges {
import {createFragmentContainer, graphql} from 'react-relay'
// ...
export default createFragmentContainer(TodoList, {
viewer: graphql`
fragment TodoList_viewer on Viewer {
allTodoes(last: 1000) {
edges {
node {
id,
complete,
import Relay from 'react-relay'
// ...
export default Relay.createContainer(Todo, {
fragments: {
todo: () => Relay.QL`
fragment on Todo {
id,
complete,
import {createFragmentContainer, graphql} from 'react-relay'
// ...
export default createFragmentContainer(Todo, {
todo: graphql`
fragment Todo_todo on Todo {
id,
complete,
text,
export default createFragmentContainer(Todo, {
todo: graphql`
fragment Todo_todo on Todo {
id,
complete,
text,
}
`,
viewer: graphql`
fragment Todo_viewer on Viewer {
export default class ChangeTodoStatusMutation extends Relay.Mutation {
static fragments = {
todo: () => Relay.QL`
fragment on Todo {
id,
complete
}
`,
viewer: () => Relay.QL`
fragment on Viewer {
import {commitMutation, graphql} from 'react-relay/compat'
const mutation = graphql`
mutation ChangeTodoStatusMutation(
$input: UpdateTodoInput!
) {
updateTodo(input: $input) {
todo {
id
complete
}
import ChangeTodoStatusMutation from '../mutations/ChangeTodoStatusMutation'
// ...
ChangeTodoStatusMutation.commit(
this.props.relay.environment,
complete,
todo,
this.props.viewer.id
)
const root = <Relay.RootContainer
Component={TodoApp}
route={new ViewerRoute()}
renderFetched={(data) => {
return (
<TodoApp
{...data}
/>
)
}}