Last active
May 3, 2021 08:07
-
-
Save nakajo2011/dbcbba1b170b13c7ea5a5ccf17bed9ec to your computer and use it in GitHub Desktop.
Apollo Client/Getting Started sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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