Skip to content

Instantly share code, notes, and snippets.

@Addono
Last active July 2, 2020 11:13
Show Gist options
  • Save Addono/eec0aacb75630faf021bdc70af73ca89 to your computer and use it in GitHub Desktop.
Save Addono/eec0aacb75630faf021bdc70af73ca89 to your computer and use it in GitHub Desktop.
Server side Apollo Client usage example
import { ApolloClient, HttpLink, InMemoryCache } from '@apollo/client'
// Create GraphQL Client for FaunaDB, replace HttpLink configuration
// with your own GraphQL endpoint configuration.
const client = new ApolloClient({
cache: new InMemoryCache(),
link: new HttpLink({
uri: 'https://graphql.fauna.com/graphql',
headers: {
"Authorization": `Bearer ${process.env.FAUNADB_SECRET}`,
},
}),
defaultOptions: {
query: {
fetchPolicy: 'no-cache',
},
}
})
// Later, use the client to query our GraphQL endpoint
const { data } = await client.query({
query: gql`
query GET_USERS {
users {
email
name
}
}
`,
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment