@forge/cli

14.1.0-next.21-experimental-554d41714.1.0-next.19-experimental-fd0ebbc
out/containers/container-command.js
~out/containers/container-command.jsModified
+40−17
Index: package/out/containers/container-command.js
===================================================================
--- package/out/containers/container-command.js
+++ package/out/containers/container-command.js
@@ -25,12 +25,13 @@
         this.dockerService = dockerService;
     }
     async createContainer(key) {
         const { id: appId } = await this.getAppConfig();
-        const mutation = `
+        const mutation = (0, cli_shared_1.graphql)(`
       mutation forge_cli_createAppContainer($input: AppContainerInput!) {
         createAppContainer(input: $input) {
           container {
+            key
             repositoryURI
           }
           success
           errors {
@@ -40,44 +41,61 @@
               statusCode
             }
           }
         }
-      }`;
-        const { response: { createAppContainer: { container, success, errors } }, requestId } = await this.client.mutate(mutation, {
+      }
+    `);
+        const { response, requestId } = await this.client.mutate(mutation, {
             input: {
                 appId,
                 containerKey: key
             }
         });
+        const { container, success, errors } = (0, cli_shared_1.requireMutationPayload)(response.createAppContainer, requestId);
         if (!success || !container) {
             const error = (0, cli_shared_1.getError)(errors);
             throw new cli_shared_1.GraphQlMutationError(`${error.message} (requestId: ${requestId || 'unknown'})`, {
                 requestId,
                 code: error.code,
                 statusCode: error.statusCode
             });
         }
-        return container;
+        return { ...container, key };
     }
     async fetchContainers() {
         const { id: appId } = await this.getAppConfig();
-        const query = `
+        const query = (0, cli_shared_1.graphql)(`
       query forge_cli_appContainers($appId: ID!) {
         appContainers(appId: $appId) {
           key
           repositoryURI
         }
-      }`;
+      }
+    `);
         const { appContainers } = await this.client.query(query, {
             appId
         });
         return appContainers ?? [];
     }
     async getContainerServiceDetails(environmentKey, serviceNames, placementId) {
         const { id: appId } = await this.getAppConfig();
-        const query = `
-      query forge_cli_appContainerServices($appId: ID!, $environmentKey: String!, $serviceNames: [String!]!, $contextFilter: AppContainerServiceContextFilter, $first: Int, $after: String) {
-        appContainerServices(appId: $appId, environmentKey: $environmentKey, serviceNames: $serviceNames, contextFilter: $contextFilter, first: $first, after: $after) {
+        const query = (0, cli_shared_1.graphql)(`
+      query forge_cli_appContainerServices(
+        $appId: ID!
+        $environmentKey: String!
+        $serviceNames: [String!]!
+        $contextFilter: AppContainerServiceContextFilter
+        $first: Int
+        $after: String
+      ) {
+        appContainerServices(
+          appId: $appId
+          environmentKey: $environmentKey
+          serviceNames: $serviceNames
+          contextFilter: $contextFilter
+          first: $first
+          after: $after
+        ) {
           services {
             key
             placementAri
             runningCount
@@ -106,9 +124,10 @@
             hasNextPage
             endCursor
           }
         }
-      }`;
+      }
+    `);
         const contextFilter = placementId
             ? {
                 type: cli_shared_1.AppContainerServiceContextFilterType.Placement,
                 value: (0, cli_shared_1.placementIdToAriString)(placementId)
@@ -135,9 +154,9 @@
         return services;
     }
     async deleteContainer(key) {
         const { id: appId } = await this.getAppConfig();
-        const mutation = `
+        const mutation = (0, cli_shared_1.graphql)(`
       mutation forge_cli_deleteAppContainer($input: AppContainerInput!) {
         deleteAppContainer(input: $input) {
           success
           errors {
@@ -147,15 +166,17 @@
               statusCode
             }
           }
         }
-      }`;
-        const { response: { deleteAppContainer: { success, errors } }, requestId } = await this.client.mutate(mutation, {
+      }
+    `);
+        const { response, requestId } = await this.client.mutate(mutation, {
             input: {
                 appId,
                 containerKey: key
             }
         });
+        const { success, errors } = (0, cli_shared_1.requireMutationPayload)(response.deleteAppContainer, requestId);
         if (!success) {
             const error = (0, cli_shared_1.getError)(errors);
             throw new cli_shared_1.GraphQlMutationError(`${error.message} (requestId: ${requestId || 'unknown'})`, {
                 requestId,
@@ -165,16 +186,17 @@
         }
     }
     async fetchLoginDetails() {
         const { id: appId } = await this.getAppConfig();
-        const query = `
+        const query = (0, cli_shared_1.graphql)(`
       query forge_cli_appContainerRegistryLogin($appId: ID!) {
         appContainerRegistryLogin(appId: $appId) {
           username
           password
           endpoint
         }
-      }`;
+      }
+    `);
         const { appContainerRegistryLogin } = await this.client.query(query, {
             appId
         });
         if (!appContainerRegistryLogin) {
@@ -183,9 +205,9 @@
         return appContainerRegistryLogin;
     }
     async fetchImages(key, startCursor, imageTag) {
         const { id: appId } = await this.getAppConfig();
-        const query = `
+        const query = (0, cli_shared_1.graphql)(`
       query forge_cli_appContainer($appId: ID!, $containerKey: String!, $after: ID, $imageTag: String) {
         appContainer(appId: $appId, containerKey: $containerKey) {
           images(first: 10, after: $after, imageTag: $imageTag) {
             edges {
@@ -202,9 +224,10 @@
               endCursor
             }
           }
         }
-      }`;
+      }
+    `);
         const { appContainer } = await this.client.query(query, {
             appId,
             containerKey: key,
             after: startCursor,