Skip to content
Snippets Groups Projects

Scaffolding for Graphql client

Merged Brian Perry requested to merge issue/api_client-3373029:graphql-client into canary
All threads resolved!
26 files
+ 482
45
Compare changes
  • Side-by-side
  • Inline
Files
26
+ 31
0
import { GraphqlClient } from "@drupal-api-client/graphql-client";
const baseUrl = import.meta.env.VITE_BASE_URL
? import.meta.env.VITE_BASE_URL
: "https://dev-drupal-api-client-poc.pantheonsite.io";
async function main() {
const graphqlClient = new GraphqlClient(baseUrl, {
authentication: {
type: "Basic",
credentials: {
username: import.meta.env.VITE_USERNAME,
password: import.meta.env.VITE_PASSWORD,
},
},
});
const query = await graphqlClient.query(
`query GetArticles {
nodeArticles(first: 10) {
nodes {
title
}
}
}`,
);
document.querySelector<HTMLDivElement>("#app")!.innerHTML = `
<pre>${JSON.stringify(query, null, 2)}</pre>`;
}
main();
Loading