Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Apollo Client/Getting Started sample2
import {gql, useQuery} from '@apollo/client';
const EXCHANGE_RATES = gql`
query GetExchangeRates {
rates(currency: "USD") {
interface RateData {
currency: string,
rate: string,
function ExchangeRates() {
const {loading, error, data} = useQuery(EXCHANGE_RATES);
if (loading) return <p>Loading...</p>;
if (error) return <p>Error :(</p>;
return RateData) => (
<div key={data.currency}>
{data.currency}: {data.rate}
export default ExchangeRates;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment