@forge/cli

14.1.0-next.21-experimental-554d41714.1.0-next.19-experimental-fd0ebbc
out/version/graphql-client.js
~out/version/graphql-client.jsModified
+56−53
Index: package/out/version/graphql-client.js
===================================================================
--- package/out/version/graphql-client.js
+++ package/out/version/graphql-client.js
@@ -22,10 +22,15 @@
     constructor(graphqlClient) {
         this.graphqlClient = graphqlClient;
     }
     async getVersionDetails(appId, environmentKey, majorVersion) {
-        const query = `
-      query forge_cli_getApplicationVersionDetails($appId: ID!, $environmentKey: String!, $firstN: Int!, $majorVersion: Int) {
+        const query = (0, cli_shared_1.graphql)(`
+      query forge_cli_getApplicationVersionDetails(
+        $appId: ID!
+        $environmentKey: String!
+        $firstN: Int!
+        $majorVersion: Int
+      ) {
         app(id: $appId) {
           environmentByKey(key: $environmentKey) {
             type
             key
@@ -77,9 +82,9 @@
             }
           }
         }
       }
-    `;
+    `);
         const result = await this.graphqlClient.query(query, {
             appId,
             environmentKey,
             firstN: 1,
@@ -106,9 +111,9 @@
             environment: result.app.environmentByKey.key
         };
     }
     async getVersionList(appId, environmentKey) {
-        const query = `
+        const query = (0, cli_shared_1.graphql)(`
       query forge_cli_getApplicationVersionList($appId: ID!, $first: Int, $after: String) {
         app(id: $appId) {
           environments {
             key
@@ -123,18 +128,19 @@
             }
           }
         }
       }
-    `;
+    `);
         const output = [];
         let cursor = undefined;
         let hasNext = undefined;
         do {
-            const result = await this.graphqlClient.query(query, {
+            const variables = {
                 appId,
                 first: 20,
                 after: cursor
-            });
+            };
+            const result = await this.graphqlClient.query(query, variables);
             if (!result.app) {
                 throw new MissingAppError();
             }
             if (!result.app.environments) {
@@ -147,9 +153,9 @@
         } while (hasNext && cursor);
         return output;
     }
     async getAppUpgradeVersionsList(appId, environmentKey) {
-        const query = `
+        const query = (0, cli_shared_1.graphql)(`
       query forge_cli_getAppUpgradeVersionsList($appId: ID!, $environmentKey: String!) {
         app(id: $appId) {
           environmentByKey(key: $environmentKey) {
             key
@@ -165,9 +171,9 @@
             }
           }
         }
       }
-    `;
+    `);
         let output = [];
         const result = await this.graphqlClient.query(query, {
             appId,
             environmentKey
@@ -192,9 +198,9 @@
         });
         return output;
     }
     async getAppUpgradableToList(appId, environmentKey, sourceVersionId) {
-        const query = `
+        const query = (0, cli_shared_1.graphql)(`
       query forge_cli_getAppUpgradableToList($appId: ID!, $environmentKey: String!, $sourceVersionId: ID!) {
         app(id: $appId) {
           environmentByKey(key: $environmentKey) {
             key
@@ -202,20 +208,18 @@
               nodes {
                 createdAt
                 id
                 version
-                upgradeableByRolloutFromVersion(
-                  sourceVersionId: $sourceVersionId
-                ) {
+                upgradeableByRolloutFromVersion(sourceVersionId: $sourceVersionId) {
                   upgradeableByRollout
                   upgradeLimit
                 }
               }
             }
           }
         }
       }
-    `;
+    `);
         let output = [];
         const result = await this.graphqlClient.query(query, {
             appId,
             environmentKey,
@@ -243,9 +247,9 @@
         });
         return output.filter((version) => version.upgradeableTo);
     }
     async createAppVersionUpgradeRollout(environmentKey, sourceVersionId, targetVersionId, sourceVersionNumber, targetVersionNumber, limit) {
-        const query = `
+        const query = (0, cli_shared_1.graphql)(`
       mutation forge_cli_createAppVersionUpgradeRollout($input: CreateAppVersionRolloutInput!) {
         ecosystem {
           createAppVersionRollout(input: $input) {
             success
@@ -265,21 +269,19 @@
             }
           }
         }
       }
-    `;
+    `);
         const variables = {
             input: {
                 sourceVersionId,
                 targetVersionId,
                 ...(limit !== undefined && { limit })
             }
         };
-        const { response: { ecosystem: { createAppVersionRollout } }, requestId } = await this.graphqlClient.mutate(query, variables);
-        if (!createAppVersionRollout) {
-            throw new cli_shared_1.GraphQlMutationError(`Unable to get a response (requestId: ${requestId || 'unknown'})`, { requestId });
-        }
-        const { success, appVersionRollout, errors, totalEligibleUpgrades, expectedRemainingUpgrades } = createAppVersionRollout;
+        const { response, requestId } = await this.graphqlClient.mutate(query, variables);
+        const { createAppVersionRollout } = (0, cli_shared_1.requireMutationPayload)(response.ecosystem, requestId);
+        const { success, appVersionRollout, errors, totalEligibleUpgrades, expectedRemainingUpgrades } = (0, cli_shared_1.requireMutationPayload)(createAppVersionRollout, requestId);
         if (success) {
             if (!appVersionRollout) {
                 throw new MissingAppVersionRolloutError();
             }
@@ -325,10 +327,15 @@
             throw new Error('Unknown error occurred during rollout creation');
         }
     }
     async getAppVersionIdentity(appId, environmentKey, majorVersion) {
-        const query = `
-      query forge_cli_getApplicationIdentityVersionDetails($appId: ID!, $environmentKey: String!, $firstN: Int!, $majorVersion: Int) {
+        const query = (0, cli_shared_1.graphql)(`
+      query forge_cli_getApplicationIdentityVersionDetails(
+        $appId: ID!
+        $environmentKey: String!
+        $firstN: Int!
+        $majorVersion: Int
+      ) {
         app(id: $appId) {
           environmentByKey(key: $environmentKey) {
             type
             versions(first: $firstN, majorVersion: $majorVersion) {
@@ -339,9 +346,9 @@
             }
           }
         }
       }
-    `;
+    `);
         const result = await this.graphqlClient.query(query, {
             appId,
             environmentKey,
             firstN: 1,
@@ -361,13 +368,10 @@
             appVersion: result.app.environmentByKey.versions?.nodes?.[0]?.version
         };
     }
     async getAppVersionRolloutsList(appId, environmentKey) {
-        const query = `
-      query forge_cli_getAppVersionRolloutsList(
-        $appId: ID!,
-        $environmentKey: String!
-      ) {
+        const query = (0, cli_shared_1.graphql)(`
+      query forge_cli_getAppVersionRolloutsList($appId: ID!, $environmentKey: String!) {
         app(id: $appId) {
           environmentByKey(key: $environmentKey) {
             id
             type
@@ -396,9 +400,9 @@
             }
           }
         }
       }
-    `;
+    `);
         const output = [];
         const result = await this.graphqlClient.query(query, {
             appId,
             environmentKey
@@ -430,27 +434,28 @@
         }));
         return output;
     }
     async getAppVersionRollout(appRolloutId) {
-        const query = `
-    query forge_cli_getAppVersionRollout($appRolloutId: ID!) {
-      ecosystem {
-        appVersionRollout(id: $appRolloutId) {
-          progress {
-            completedUpgradeCount
-            failedUpgradeCount
-            pendingUpgradeCount
+        const query = (0, cli_shared_1.graphql)(`
+      query forge_cli_getAppVersionRollout($appRolloutId: ID!) {
+        ecosystem {
+          appVersionRollout(id: $appRolloutId) {
+            progress {
+              completedUpgradeCount
+              failedUpgradeCount
+              pendingUpgradeCount
+            }
+            sourceVersionId
+            targetVersionId
+            status
+            id
+            appId
+            completedAt
+            upgradeLimit
           }
-          sourceVersionId
-          targetVersionId
-          status
-          id
-          appId
-          completedAt
-          upgradeLimit
         }
       }
-    }`;
+    `);
         const result = await this.graphqlClient.query(query, {
             appRolloutId
         });
         if (!result?.ecosystem?.appVersionRollout?.id) {
@@ -469,9 +474,9 @@
             upgradeLimit: appVersionRollout.upgradeLimit ?? undefined
         };
     }
     async cancelAppVersionUpgradeRollout(appRolloutId, environmentKey) {
-        const query = `
+        const query = (0, cli_shared_1.graphql)(`
       mutation forge_cli_cancelAppVersionUpgradeRollout($input: CancelAppVersionRolloutInput!) {
         ecosystem {
           cancelAppVersionRollout(input: $input) {
             success
@@ -484,19 +489,17 @@
             }
           }
         }
       }
-    `;
+    `);
         const variables = {
             input: {
                 id: appRolloutId
             }
         };
-        const { response: { ecosystem: { cancelAppVersionRollout } }, requestId } = await this.graphqlClient.mutate(query, variables);
-        if (!cancelAppVersionRollout) {
-            throw new cli_shared_1.GraphQlMutationError(`Unable to get a response (requestId: ${requestId || 'unknown'})`, { requestId });
-        }
-        const { success, errors } = cancelAppVersionRollout;
+        const { response, requestId } = await this.graphqlClient.mutate(query, variables);
+        const { cancelAppVersionRollout } = (0, cli_shared_1.requireMutationPayload)(response.ecosystem, requestId);
+        const { success, errors } = (0, cli_shared_1.requireMutationPayload)(cancelAppVersionRollout, requestId);
         if (!success && errors && errors.length > 0) {
             const errorList = [];
             errors.forEach((error) => {
                 if (error?.extensions?.errorType && error.message) {