Skip to content

Instantly share code, notes, and snippets.

@nakajo2011
Last active May 3, 2021 08:07
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 nakajo2011/dbcbba1b170b13c7ea5a5ccf17bed9ec to your computer and use it in GitHub Desktop.
Save nakajo2011/dbcbba1b170b13c7ea5a5ccf17bed9ec to your computer and use it in GitHub Desktop.
Apollo Client/Getting Started sample
import fetch from 'cross-fetch';
import { gql, ApolloClient, HttpLink, InMemoryCache } from '@apollo/client';
const client = new ApolloClient({
link: new HttpLink({ uri: 'https://48p1r2roz4.sse.codesandbox.io', fetch }),
cache: new InMemoryCache()
});
client
.query({
query: gql`
query GetRates {
rates(currency: "USD") {
currency
}
}
`
})
.then(result => console.log(JSON.stringify(result, null, ' ')));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment