// query github api using graphql
import { ApolloClient, HttpLink, InMemoryCache } from "@apollo/client";
import { RepositoryDocument } from "@hk/github-graphql";
// print something from the github graphql api
export async function demo() {
const client = new ApolloClient({
cache: new InMemoryCache(),
link: new HttpLink({
uri: "https://api.github.com/graphql",
headers: {
authorization: `Bearer ${Deno.env.get("GITHUB_TOKEN")}`,
"User-Agent": "github-graphql package",
},
}),
});
const result = await client.query({
query: RepositoryDocument,
variables: {
owner: "tauri-apps",
name: "tauri",
},
});
console.log(`stargazer count: ${result.data.repository?.stargazerCount}`);
}
await demo();
// query github api using graphql
import { ApolloClient, HttpLink, InMemoryCache } from "@apollo/client";
import { RepositoryDocument } from "@hk/github-graphql";
// print something from the github graphql api
export async function demo() {
const client = new ApolloClient({
cache: new InMemoryCache(),
link: new HttpLink({
uri: "https://api.github.com/graphql",
headers: {
authorization: `Bearer ${Deno.env.get("GITHUB_TOKEN")}`,
"User-Agent": "github-graphql package",
},
}),
});
const result = await client.query({
query: RepositoryDocument,
variables: {
owner: "tauri-apps",
name: "tauri",
},
});
console.log(`stargazer count: ${result.data.repository?.stargazerCount}`);
}
await demo();