UNPKG

sanity

Version:

Sanity is a real-time content infrastructure with a scalable, hosted backend featuring a Graph Oriented Query Language (GROQ), asset pipelines and fast edge caches

39 lines (38 loc) 1.23 kB
import { getClientUrl } from "./_internal.js"; async function listGraphQLApis(args, context) { const { apiClient, output, chalk } = context, client = apiClient({ requireUser: !0, requireProject: !0 }).config({ apiVersion: "2023-08-01" }); let endpoints; try { endpoints = await client.request({ url: "/apis/graphql", method: "GET" }); } catch (err) { throw err; } if (!endpoints || endpoints.length === 0) { output.print("This project doesn't have any GraphQL endpoints deployed."); return; } output.print("Here are the GraphQL endpoints deployed for this project:"), endpoints.forEach((endpoint, index) => { const { dataset, tag } = endpoint, url = getClientUrl(client, `graphql/${dataset}/${tag}`); output.print(`${index + 1}. ${chalk.bold("Dataset:")} ${dataset}`), output.print(` ${chalk.bold("Tag:")} ${tag}`), output.print(` ${chalk.bold("Generation:")} ${endpoint.generation}`), output.print(` ${chalk.bold("Playground:")} ${endpoint.playgroundEnabled}`), output.print(` ${chalk.bold("URL:")} ${url} `); }); } export { listGraphQLApis as default }; //# sourceMappingURL=listApisAction.js.map