From 9cf9721abe7f652ab94fc0af7f9cb9ced8a39ebb Mon Sep 17 00:00:00 2001 From: Wilfred Asomani Date: Fri, 18 Aug 2023 13:52:28 +0000 Subject: [PATCH] web/satellite: use create project http endpoint This change uses the new POST projects endpoint in place of the GraphQL createProject query. Issue: https://github.com/storj/storj/issues/6195 Change-Id: I1776b8b0e8656d2f5fa4219df020615bcc0f2543 --- web/satellite/src/api/projects.ts | 32 ++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/web/satellite/src/api/projects.ts b/web/satellite/src/api/projects.ts index b263647d7..c2a506223 100644 --- a/web/satellite/src/api/projects.ts +++ b/web/satellite/src/api/projects.ts @@ -29,24 +29,30 @@ export class ProjectsApiGql extends BaseGql implements ProjectsApi { * @throws Error */ public async create(projectFields: ProjectFields): Promise { - const query = - `mutation($name: String!, $description: String!) { - createProject( - input: { - name: $name, - description: $description, - } - ) {publicId} - }`; - - const variables = { + const data = { name: projectFields.name, description: projectFields.description, }; - const response = await this.mutate(query, variables); + const response = await this.http.post(this.ROOT_PATH, JSON.stringify(data)); + const result = await response.json(); + if (response.ok) { + return new Project( + result.id, + result.name, + result.description, + result.createdAt, + result.ownerId, + false, + result.memberCount, + ); + } - return new Project(response.data.createProject.publicId, variables.name, variables.description, '', projectFields.ownerId); + throw new APIError({ + status: response.status, + message: result.error || 'Could not create project', + requestID: response.headers.get('x-request-id'), + }); } /**