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
const { ApolloServer, gql } = require('apollo-server'); | |
// Construct a schema, using GraphQL schema language | |
const typeDefs = gql` | |
type Query { | |
hello: String | |
} | |
`; | |
// Provide resolver functions for your schema fields |
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
import React from "react"; | |
import { ApolloConsumer } from "react-apollo"; | |
import Link from "./Link"; | |
const FilterLink = ({ filter, children }) => ( | |
<ApolloConsumer> | |
{cache => ( | |
<Link | |
onClick={() => cache.writeData({ data: { visibilityFilter: filter } })} |
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
import React from "react"; | |
import { Query } from "react-apollo"; | |
import gql from "graphql-tag"; | |
const GET_TODOS = gql` | |
{ | |
todos { | |
id | |
type | |
} |
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
import React from "react"; | |
import { Mutation } from "react-apollo"; | |
import gql from "graphql-tag"; | |
const TOGGLE_TODO = gql` | |
mutation ToggleTodo($id: Int!) { | |
toggleTodo(id: $id) { | |
id | |
completed | |
} |
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
import React from "react"; | |
import gql from "graphql-tag"; | |
import { Query } from "react-apollo"; | |
const GET_DOGS = gql` | |
{ | |
dogs { | |
id | |
breed | |
} |
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
import React from 'react'; | |
import { ApolloConsumer, Query } from 'react-apollo'; | |
import gql from 'graphql-tag'; | |
const SimpleMutation = () => ( | |
<ApolloConsumer> | |
{(cache) => ( | |
<button onClick={() => cache.writeData({ data: { status: 'yo' }})}>Click me!</button> | |
)} | |
</ApolloConsumer> |
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
import React, { Fragment } from "react"; | |
function Placeholder({ delayMs, fallbackUI, children }) { | |
return ( | |
<React.Timeout ms={delayMs}> | |
{didTimeout => { | |
return ( | |
<Fragment> | |
<span hidden={didTimeout}>{children}</span> | |
{didTimeout ? fallbackUI : null} |
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
import React from "react"; | |
import ReactDOM from "react-dom"; | |
export class AsyncValue extends React.Component { | |
state = { asyncValue: this.props.defaultValue }; | |
deferSetState(state) { | |
ReactDOM.unstable_deferredUpdates(() => { | |
this.setState(state); | |
}); | |
} |
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
import React from "react"; | |
import ReactDOM from "react-dom"; | |
export class AsyncValue extends React.Component { | |
state = { asyncValue: this.props.defaultValue }; | |
deferSetState(state) { | |
ReactDOM.unstable_deferredUpdates(() => { | |
this.setState(state); | |
}); | |
} |
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
import React from "react"; | |
import ReactDOM from "react-dom"; | |
export class AsyncValue extends React.Component { | |
state = { asyncValue: this.props.defaultValue }; | |
deferSetState(state) { | |
ReactDOM.unstable_deferredUpdates(() => { | |
this.setState(state); | |
}); | |
} |
NewerOlder