🏗️ Setup (NodeJS)
- npm
- Yarn
npm install @apollo/client graphql
yarn add @apollo/client graphql
Initialize the Zallo client
import { ApolloClient, InMemoryCache } from '@apollo/client';
const zallo = new ApolloClient({
uri: 'https://api.zallo.io/graphql',
cache: new InMemoryCache(),
credentials: 'include', // Include cookies
});
🔒 Authenticating your requests
Obtain your auth token
// TODO: obtain token
Add the token to your request headers
const zallo = new ApolloClient({
uri: 'https://api.zallo.io/graphql',
cache: new InMemoryCache(),
credentials: 'include', // Include cookies
headers: {
Authorization: `Bearer ${token}`,
},
});
🎉 That's it! You're ready to go
Test that your client is configured correctly by running the following query
const { data } = await zallo.query({
query: gql`
query DeviceId {
device {
id
}
}
`,
});
Visit the playground to try things out