Skip to content

Instantly share code, notes, and snippets.

@hwillson
Last active August 6, 2019 10:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hwillson/80629aa1d0a3fcfd6a6c61149c74c80e to your computer and use it in GitHub Desktop.
Save hwillson/80629aa1d0a3fcfd6a6c61149c74c80e to your computer and use it in GitHub Desktop.
React Apollo 3 - useQuery
const LAST_LAUNCH = gql`
query lastLaunch {
launch {
id
timestamp
}
}
`;
export function LastLaunch() {
const { loading, data } = useQuery(LAST_LAUNCH);
return (
<div>
<h1>Last Launch</h1>
{loading ? <p>Loading</p> : <p>Timestamp: {data.launch.timestamp}</p>}
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment