Skip to content

Instantly share code, notes, and snippets.

@peggyrayzis
Last active February 15, 2018 08:39
Show Gist options
  • Save peggyrayzis/1beeb43c2aa553db67c568241d5ef956 to your computer and use it in GitHub Desktop.
Save peggyrayzis/1beeb43c2aa553db67c568241d5ef956 to your computer and use it in GitHub Desktop.
Apollo Boost query
import React from 'react';
import { gql } from 'apollo-boost';
import { Query } from 'react-apollo';
const GET_DOG = gql`
query {
dog(breed: "bulldog") {
id
displayImage
}
}
`
export const App = () => (
<Query query={GET_DOG}>
{({ loading, error, data }) => {
if (loading) return <div>Loading...</div>;
if (error) return <div>Error :(</div>;
return <img src={data.dog.displayImage} />
}}
</Query>
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment