Skip to content

Instantly share code, notes, and snippets.

View marcaaron's full-sized avatar
🐌

Marc Glasser marcaaron

🐌
View GitHub Profile
import React, { Component } from 'react';
import { gql } from 'apollo-boost';
import { withApollo } from 'react-apollo';
class Query extends Component {
state = {
data: null,
loading: true
}
import React from 'react';
import { gql } from 'apollo-boost';
const FakeQuery = (props) => {
const { query } = props;
const data = {
loading: false,
error: null,
data: null
}
import React from 'react';
import { gql } from 'apollo-boost';
const FakeQuery = (props) => {
return props.children('Hello World');
}
const MyComponent = (props) => {
return (
<FakeQuery>
const FakeQuery = (props) => {
return props.children();
}
const MyComponent = (props) => {
return (
<FakeQuery>
{ () => { return null } }
</FakeQuery>
)
import React from "react";
import { Query } from "react-apollo";
import { gql } from "apollo-boost";
const MyComponent = props =>
<Query
query={MY_QUERY}>
{({ data, loading, error }) => {
if (loading) return 'Loading';
if (error) return `Error!: ${error}`;
import React from 'react'
import { gql } from 'apollo-boost'
import { graphql } from 'react-apollo'
const MyComponent = ({data}) => {
const { loading, error, things} = data;
if (loading) return 'Loading'
if (error) return `Error: ${error}`
return (
<div>