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
<User id={id}> | |
{({ user }) => ( | |
<UserStartup user={user}> | |
{ | |
({ data: { startup, startup: { correspondingRepo: repo }}}) => | |
<UI repo={repo} email={user.email} startup={startup}/> | |
} | |
</UserStartup> | |
)} | |
</User> |
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 const GetAndShowData = ({ userId }) => ( | |
<Query query={GET_USER} variables={{ userId }}> | |
{({ loading, data: { email } }) => ( | |
<Query query={GET_HACKERNEWS_STARTUP} variables={{ email }}> | |
{({ loading, data: { startup } }) => ( | |
<Query query={GET_REPO} variables = {{ startup }}> | |
{({loading, error, data: { correspondingRepo } }) => { | |
if (loading) return <p>Loading...</p>; | |
if (error) return <p>Error...</p>; | |
return ( |
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 GetPosts = () => ( | |
<Query query={GET_POSTS}> | |
{({ loading, error, data }) => { | |
if (loading) return "Loading..."; | |
if (error) return "Error"; | |
return ( | |
<div> | |
{data.posts.map(post => ( | |
<p key={post.id}> { post.title } </p> | |
))} |
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 FeedData = ({ match }) => ( | |
<Query | |
query={FEED_QUERY} | |
variables={{ | |
type: match.params.type.toUpperCase() || "TOP", | |
offset: 0, | |
limit: 10 | |
}} | |
fetchPolicy="cache-and-network" | |
> |
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 DogPhoto = ({ breed }) => ( | |
<Query | |
query={GET_DOG_PHOTO} | |
variables={{ breed }} | |
skip={!breed} | |
pollInterval={500} | |
notifyOnNetworkStatusChange | |
> | |
{({ loading, error, data, networkStatus }) => { | |
if (networkStatus == 6) return "Polling for data..Stay tuned!"; |
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 const GetACar = () => ( | |
<Query query={GET_A_CAR} notifyOnNetworkStatusChange> | |
{({ loading, error, data, refetch, networkStatus }) => { | |
if (networkStatus === 4) return "Refetching..."; | |
if (loading) return <p>Loading...</p>; | |
if (error) return <p>Error...</p>; | |
return ( | |
<div> | |
<p> Color: {data.car.color} </p> |
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 { adopt } from 'react-adopt'; | |
import { gql } from 'apollo-boost'; | |
const INCREASE_COUNT = gql` | |
mutation increaseCount { | |
increaseCount { | |
id | |
currentCount |
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 { render } from 'react-dom' | |
import { adopt } from 'react-adopt' | |
import { Value } from 'react-powerplug' | |
const Composed = adopt({ | |
greet: ({ initialGreet, render }) => ( | |
<Value initial={initialGreet}>{render}</Value> | |
), | |
name: <Value initial="John" />, |
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 App = () => ( | |
<TodoContainer> | |
{({ todos, createTodo, deleteTodo }) => /* ... */ } | |
</TodoContainer> | |
) |
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 { gql } from 'apollo-boost' | |
import { Query, Mutation } from 'react-apollo' | |
import { adopt } from 'react-adopt' | |
const ALL_TODOS = gql` | |
{ | |
todos: allTodoes { | |
id | |
title | |
completed |