Skip to content

Commit

Permalink
[core] GraphQL: Format output from graphql list command a little better
Browse files Browse the repository at this point in the history
  • Loading branch information
saasen committed Feb 27, 2020
1 parent d5eb7d3 commit 7a27fe4
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions packages/@sanity/core/src/actions/graphql/listApisAction.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = async function listApisAction(args, context) {
const {apiClient, output} = context
const {apiClient, output, chalk} = context

const client = apiClient({
requireUser: true,
Expand All @@ -20,14 +20,25 @@ module.exports = async function listApisAction(args, context) {
}
}

endpoints = [{
dataset: 'production',
tag: 'default',
generation: 'gen1',
playgroundEnabled: false
}, {
dataset: 'staging',
tag: 'next',
generation: 'gen2',
playgroundEnabled: true
}]

if (endpoints && endpoints.length > 0) {
output.print('Here are the GraphQL endpoints deployed for this project:')
endpoints.forEach((endpoint, index) => {
output.print(`* [${index + 1}] `)
output.print(` ** Dataset: ${endpoint.dataset}`)
output.print(` ** Tag: ${endpoint.tag}`)
output.print(` ** Generation: ${endpoint.generation}`)
output.print(` ** Playground: ${endpoint.playgroundEnabled}\n`)
output.print(`${index + 1}. ${chalk.bold('Dataset:')} ${endpoint.dataset}`)
output.print(` ${chalk.bold('Tag:')} ${endpoint.tag}`)
output.print(` ${chalk.bold('Generation:')} ${endpoint.generation}`)
output.print(` ${chalk.bold('Playground:')} ${endpoint.playgroundEnabled}\n`)
})
}

Expand Down

0 comments on commit 7a27fe4

Please sign in to comment.