prismatic-io / prism

Prismatic's CLI tool for managing prismatic.io resources from the command line
MIT License
20 stars 3 forks source link

Add --print-requests flag to most commands #106

Closed taylorreece closed 1 month ago

taylorreece commented 3 months ago

Sometimes, it's handy to see what GraphQL queries and mutations prism issues. This adds a new flag, --print-requests, to any command that runs a GraphQL query or mutation. When the flag is present, the GraphQL query/mutation along with its variables are logged out.

For example,

> prism instances:list --print-requests --customer Q3VzdG9tZXI6YjBmZDAyZTItYmE1OC00NzE0LWJhYzgtMDMwNWM5N2JiY2Vj
=================================
GraphQL Request: 
          query listInstances($customer: ID, $integration: ID, $after: String) {
            instances(
              customer: $customer
              integration: $integration
              isSystem: false
              after: $after
            ) {
              nodes {
                id
                name
                description
                enabled
                customer {
                  id
                  name
                  externalId
                }
              }
              pageInfo {
                hasNextPage
                endCursor
              }
            }
          }

Variables: {"customer":"Q3VzdG9tZXI6YjBmZDAyZTItYmE1OC00NzE0LWJhYzgtMDMwNWM5N2JiY2Vj","after":""}
=================================
 Name                     Customer  Description                                                               
 ──────────────────────── ───────── ───────────────────────────────────────────────────────────────────────── 
 PSQL On-Prem             Acme Corp                                                                           
 Salesforce               Acme Corp                                                                           
 My First Integration     Acme Corp Send a Slack message indicating how many to-do items are marked complete. 
 HMAC Test                Acme Corp