Skip to content

Instantly share code, notes, and snippets.

@leonascimento
Last active November 23, 2018 09:59
Show Gist options
  • Save leonascimento/3c072d8a1bede59577e0f5f27cf12571 to your computer and use it in GitHub Desktop.
Save leonascimento/3c072d8a1bede59577e0f5f27cf12571 to your computer and use it in GitHub Desktop.
const ALL_CUSTOMERS = gql`
query {
allCustomer {
edges {
node {
id
name
description
}
}
}
}
`;
const Users = () => {
return(
<Query query={ALL_CUSTOMERS}>
{({ loading, data, error }) => {
console.log(data);
if (loading) return <p>Loading...</p>;
if (error) return <p>error</p>;
return(
<div>
{data.edgs.nodes.map(customer => customer.name)}
</div>
);
}}
</Query>
);
};
document.addEventListener('DOMContentLoaded', () => {
initializeStore();
ReactDOM.render(
<ApolloProvider client={client}>
<Users />
</ApolloProvider>,
document.querySelector('#app'),
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment