You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
561 B
30 lines
561 B
import {
|
|
ApolloClient,
|
|
InMemoryCache,
|
|
createHttpLink
|
|
} from "@apollo/client";
|
|
|
|
import { setContext } from "@apollo/client/link/context";
|
|
|
|
export async function createClient() {
|
|
const httpLink = createHttpLink({
|
|
uri: "https://api.github.com/graphql",
|
|
});
|
|
|
|
const authLink = setContext((_, { headers }) => {
|
|
return {
|
|
headers: {
|
|
...headers,
|
|
authorization: `Bearer ${process.env.GITHUB_ACCESS_TOKEN}`,
|
|
}
|
|
}
|
|
});
|
|
|
|
const client = new ApolloClient({
|
|
link: authLink.concat(httpLink),
|
|
cache: new InMemoryCache()
|
|
});
|
|
|
|
return client;
|
|
}
|
|
|
|
|