Repository: FalkorDB/falkordb-browser
Pull request #734: Update apicalls
Author: login: Naseem77
Created: 2025-03-09T12:51:58Z | Merged: 2025-03-10T08:27:47Z



Diff:
diff --git a/e2e/config/urls.json b/e2e/config/urls.json
index 788902425..fe46e2302 100644
--- a/e2e/config/urls.json
+++ b/e2e/config/urls.json
@@ -1,11 +1,10 @@
 {
     "api": {
-        "addGraphUrl": "http://localhost:3000/api/graph/",
+        "graphUrl": "http://localhost:3000/api/graph/",
         "LoginApiUrl": "http://localhost:3000/api/auth/providers",
-        "deleteGraphUrl": "http://localhost:3000/api/graph/",
+        "LogoutApiUrl": "http://localhost:3000/api/auth/signout",
         "settingsConfig": "http://localhost:3000/api/graph?config=",
-        "settingsUsers": "http://localhost:3000/api/user",
-        "runQueryUrl": "http://localhost:3000/api/graph/"
+        "settingsUsers": "http://localhost:3000/api/user"
     },
   
     "falkorDBWeb": "https://www.falkordb.com/",
diff --git a/e2e/infra/api/apiRequests.ts b/e2e/infra/api/apiRequests.ts
index b97879c24..73d539d4c 100644
--- a/e2e/infra/api/apiRequests.ts
+++ b/e2e/infra/api/apiRequests.ts
@@ -3,7 +3,7 @@
 import { APIRequestContext, request } from "@playwright/test"
 
 
-const getRequest = async (url: string, body: any, availableRequest?: APIRequestContext, headers?: Record<string, string>) => {
+const getRequest = async (url: string, body?: any, availableRequest?: APIRequestContext, headers?: Record<string, string>) => {
   const requestOptions = {
     data: body,
     headers: headers || undefined,
@@ -14,7 +14,7 @@ const getRequest = async (url: string, body: any, availableRequest?: APIRequestC
   return response;
 };
 
-const postRequest = async (url: string, body: any, availableRequest?: APIRequestContext, headers?: Record<string, string>) => {
+const postRequest = async (url: string, body?: any, availableRequest?: APIRequestContext, headers?: Record<string, string>) => {
   const requestOptions = {
     data: body,
     headers: headers || undefined,
@@ -36,6 +36,15 @@ const deleteRequest = async (url: string, body?: any, headers?: Record<string, s
   return response;
 };
 
+const patchRequest = async (url: string, body?: any, availableRequest?: APIRequestContext, headers?: Record<string, string>) => {
+  const requestOptions = {
+    data: body,
+    headers: headers || undefined,
+  };
 
+  const requestContext = availableRequest || (await request.newContext());
+  const response = await requestContext.patch(url, requestOptions);
+  return response;
+};
 
-export { getRequest, deleteRequest, postRequest }
\ No newline at end of file
+export { getRequest, deleteRequest, postRequest, patchRequest }
\ No newline at end of file
diff --git a/e2e/logic/api/apiCalls.ts b/e2e/logic/api/apiCalls.ts
index 43342b9a6..d2a059134 100644
--- a/e2e/logic/api/apiCalls.ts
+++ b/e2e/logic/api/apiCalls.ts
@@ -1,7 +1,7 @@
 /* eslint-disable class-methods-use-this */
 /* eslint-disable @typescript-eslint/no-explicit-any */
 
-import { deleteRequest, getRequest, postRequest } from "../../infra/api/apiRequests";
+import { deleteRequest, getRequest, patchRequest, postRequest } from "../../infra/api/apiRequests";
 import urls from '../../config/urls.json'
 import { AddGraphResponse } from "./responses/addGraphResponse";
 import { RemoveGraphResponse } from "./responses/removeGraphResponse";
@@ -11,54 +11,156 @@ import { CreateUsersResponse } from "./responses/createUsersResponse";
 import { DeleteUsersResponse } from "./responses/deleteUsersResponse";
 import { RunQueryResponse } from "./responses/runQueryResponse";
 import { GetUsersResponse } from "./responses/getUsersResponse";
+import { DuplicateGraphresponse } from "./responses/duplicateGraph";
+import { ChangeGraphNameResponse } from "./responses/changeGraphNameResponse";
+import { AuthCredentialsResponse } from "./responses/LoginResponse";
+import { LogoutResponse } from "./responses/logoutResponse";
+import { AddSchemaResponse } from "./responses/addSchemaResponse";
 
 export default class ApiCalls {
 
-    async addGraph(graphName: string, data?: any): Promise<AddGraphResponse> {
-        const result = await getRequest(`${urls.api.addGraphUrl + graphName}?query=RETURN%201`, data)
-        const jsonData = await result.json();
-        return jsonData
+    async login(): Promise<AuthCredentialsResponse> {
+        try {
+            const result = await getRequest(`${urls.api.LoginApiUrl}`);
+            return await result.json();
+        } catch (error) {
+            throw new Error("Failed to login. Please try again.");
+        }
     }
-
+    
+    async logout(): Promise<LogoutResponse> {
+        try {
+            const result = await postRequest(`${urls.api.LogoutApiUrl}`);
+            return await result.json();
+        } catch (error) {
+            throw new Error("Failed to logout. Please try again.");
+        }
+    }
+    
+    async addGraph(graphName: string): Promise<AddGraphResponse> {
+        try {
+            const result = await getRequest(`${urls.api.graphUrl + graphName}?query=RETURN%201`);
+            return await result.json();
+        } catch (error) {
+            throw new Error("Failed to add graph.");
+        }
+    }
+    
+    async getGraphs(): Promise<GetGraphsResponse> {
+        try {
+            const result = await getRequest(`${urls.api.graphUrl}`);
+            return await result.json();
+        } catch (error) {
+            throw new Error("Failed to retrieve graphs.");
+        }
+    }
+    
     async removeGraph(graphName: string): Promise<RemoveGraphResponse> {
-        const result = await deleteRequest(urls.api.deleteGraphUrl + graphName)
-        const jsonData = await result.json();
-        return jsonData
+        try {
+            const result = await deleteRequest(urls.api.graphUrl + graphName);
+            return await result.json();
+        } catch (error) {
+            throw new Error("Failed to remove graph.");
+        }
     }
-
-    async modifySettingsRole(roleName: string, roleValue: string, data?: any): Promise<ModifySettingsRoleResponse> {
-        const result = await postRequest(`${urls.api.settingsConfig + roleName}&value=${roleValue}`, data)
-        const jsonData = await result.json();
-        return jsonData
+    
+    async changeGraphName(sourceGraph: string, destinationGraph: string): Promise<ChangeGraphNameResponse> {
+        try {
+            const result = await patchRequest(urls.api.graphUrl + destinationGraph + "?sourceName=" + sourceGraph);
+            return await result.json();
+        } catch (error) {
+            throw new Error("Failed to change graph name.");
+        }
     }
-
-    async getSettingsRoleValue(roleName: string, data?: any): Promise<GetSettingsRoleValue> {
-        const result = await getRequest(urls.api.settingsConfig + roleName, data)
-        const jsonData = await result.json();
-        return jsonData
+    
+    async exportGraph(graphName: string): Promise<void> {
+        try {
+            const result = await getRequest(urls.api.graphUrl + graphName + "/export");
+            await result.json();
+        } catch (error) {
+            throw new Error("Failed to export graph.");
+        }
     }
-
-    async getUsers(data?: any): Promise<GetUsersResponse> {
-        const result = await getRequest(urls.api.settingsUsers, data)
-        const jsonData = await result.json();
-        return jsonData
+    
+    async duplicateGraph(sourceGraph: string, destinationGraph: string, data?: any): Promise<DuplicateGraphresponse> {
+        try {
+            const result = await postRequest(urls.api.graphUrl + destinationGraph + "?sourceName=" + sourceGraph, data);
+            return await result.json();
+        } catch (error) {
+            throw new Error("Failed to duplicate graph.");
+        }
     }
-
+    
+    async runQuery(query: string): Promise<RunQueryResponse> {
+        try {
+            const result = await getRequest(urls.api.graphUrl + query);
+            return await result.json();
+        } catch (error) {
+            throw new Error("Failed to run query.");
+        }
+    }
+    
+    async modifySettingsRole(roleName: string, roleValue: string): Promise<ModifySettingsRoleResponse> {
+        try {
+            const result = await postRequest(`${urls.api.settingsConfig + roleName}&value=${roleValue}`);
+            return await result.json();
+        } catch (error) {
+            throw new Error("Failed to modify settings role.");
+        }
+    }
+    
+    async getSettingsRoleValue(roleName: string): Promise<GetSettingsRoleValue> {
+        try {
+            const result = await getRequest(urls.api.settingsConfig + roleName);
+            return await result.json();
+        } catch (error) {
+            throw new Error("Failed to get settings role value.");
+        }
+    }
+    
+    async getUsers(): Promise<GetUsersResponse> {
+        try {
+            const result = await getRequest(urls.api.settingsUsers);
+            return await result.json();
+        } catch (error) {
+            throw new Error("Failed to retrieve users.");
+        }
+    }
+    
     async createUsers(data?: any): Promise<CreateUsersResponse> {
-        const result = await postRequest(urls.api.settingsUsers, data)
-        const jsonData = await result.json();
-        return jsonData
+        try {
+            const result = await postRequest(urls.api.settingsUsers, data);
+            return await result.json();
+        } catch (error) {
+            throw new Error("Failed to create users.");
+        }
     }
-
+    
     async deleteUsers(data?: any): Promise<DeleteUsersResponse> {
-        const result = await deleteRequest(urls.api.settingsUsers, data)
-        const jsonData = await result.json();
-        return jsonData
+        try {
+            const result = await deleteRequest(urls.api.settingsUsers, data);
+            return await result.json();
+        } catch (error) {
+            throw new Error("Failed to delete users.");
+        }
     }
-
-    async runQuery(query: string, data?: any): Promise<RunQueryResponse> {
-        const result = await getRequest(urls.api.runQueryUrl + query, data)
-        const jsonData = await result.json();
-        return jsonData
+    
+    async addSchema(schemaName: string): Promise<AddSchemaResponse> {
+        try {
+            const result = await getRequest(`${urls.api.graphUrl + schemaName}?query=RETURN%201`);
+            return await result.json();
+        } catch (error) {
+            throw new Error("Failed to add schema.");
+        }
+    }
+    
+    async removeSchema(schemaName: string): Promise<RemoveGraphResponse> {
+        try {
+            const result = await deleteRequest(urls.api.graphUrl + schemaName);
+            return await result.json();
+        } catch (error) {
+            throw new Error("Failed to remove schema.");
+        }
     }
+    
 }
\ No newline at end of file
diff --git a/e2e/logic/api/responses/LoginResponse.ts b/e2e/logic/api/responses/LoginResponse.ts
new file mode 100644
index 000000000..8a4b62d38
--- /dev/null
+++ b/e2e/logic/api/responses/LoginResponse.ts
@@ -0,0 +1,9 @@
+export interface AuthCredentialsResponse {
+    credentials: {
+        id: string;
+        name: string;
+        type: string;
+        signinUrl: string;
+        callbackUrl: string;
+    };
+}
diff --git a/e2e/logic/api/responses/addSchemaResponse.ts b/e2e/logic/api/responses/addSchemaResponse.ts
new file mode 100644
index 000000000..e43b2af0d
--- /dev/null
+++ b/e2e/logic/api/responses/addSchemaResponse.ts
@@ -0,0 +1,6 @@
+export interface AddSchemaResponse {
+    result: {
+        metadata: string[];
+        data: Array<Record<string, number>>;
+    };
+}
diff --git a/e2e/logic/api/responses/changeGraphNameResponse.ts b/e2e/logic/api/responses/changeGraphNameResponse.ts
new file mode 100644
index 000000000..71632fbac
--- /dev/null
+++ b/e2e/logic/api/responses/changeGraphNameResponse.ts
@@ -0,0 +1,4 @@
+export interface ChangeGraphNameResponse {
+    data: boolean;
+}
+  
\ No newline at end of file
diff --git a/e2e/logic/api/responses/duplicateGraph.ts b/e2e/logic/api/responses/duplicateGraph.ts
new file mode 100644
index 000000000..5e356c26b
--- /dev/null
+++ b/e2e/logic/api/responses/duplicateGraph.ts
@@ -0,0 +1,3 @@
+export interface DuplicateGraphresponse {
+    success: string;
+}
diff --git a/e2e/logic/api/responses/getGraphsResponse.ts b/e2e/logic/api/responses/getGraphsResponse.ts
new file mode 100644
index 000000000..a4d8aea92
--- /dev/null
+++ b/e2e/logic/api/responses/getGraphsResponse.ts
@@ -0,0 +1,3 @@
+interface GetGraphsResponse {
+    result: string[];
+}
\ No newline at end of file
diff --git a/e2e/logic/api/responses/logoutResponse.ts b/e2e/logic/api/responses/logoutResponse.ts
new file mode 100644
index 000000000..7add994c6
--- /dev/null
+++ b/e2e/logic/api/responses/logoutResponse.ts
@@ -0,0 +1,3 @@
+export interface LogoutResponse {
+    url: string;
+}
diff --git a/e2e/logic/api/responses/removeSchemaResponse.ts b/e2e/logic/api/responses/removeSchemaResponse.ts
new file mode 100644
index 000000000..7e1e71cf4
--- /dev/null
+++ b/e2e/logic/api/responses/removeSchemaResponse.ts
@@ -0,0 +1,3 @@
+export interface RemoveSchemaResponse {
+    message: string;
+}


Reviews:
user: login: gemini-code-assist[bot]
body: Hello @Naseem77, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

## Summary of Changes
This pull request updates the API calls in the e2e tests. It modifies the `urls.json` file to update the API endpoints, and it updates the `apiRequests.ts` file to allow optional bodies for GET and POST requests and to add a new `patchRequest` function. It also updates the `apiCalls.ts` file to use the new API endpoints and to add new API calls for login, logout, change graph name, export graph, duplicate graph, add schema, and remove schema. Finally, it adds new response interfaces for the new API calls.

### Highlights
* **API Endpoint Updates**: The `urls.json` file has been updated to reflect changes in the API endpoints. `addGraphUrl`, `deleteGraphUrl`, and `runQueryUrl` have been consolidated into a single `graphUrl`. Also, `LogoutApiUlr` has been added.
* **Optional Request Bodies**: The `getRequest` and `postRequest` functions in `apiRequests.ts` have been updated to allow for optional request bodies.
* **PATCH Request Support**: A new `patchRequest` function has been added to `apiRequests.ts` to support PATCH requests.
* **New API Calls**: The `apiCalls.ts` file has been updated to include new API calls for login, logout, change graph name, export graph, duplicate graph, add schema, and remove schema.
* **Response Interfaces**: New response interfaces have been added to the `e2e/logic/api/responses` directory for the new API calls.

### Changelog
<details>
<summary>Click here to see the changelog</summary>

* **e2e/config/urls.json**
  * Consolidated `addGraphUrl`, `deleteGraphUrl`, and `runQueryUrl` into a single `graphUrl`.
  * Added `LogoutApiUlr`.
* **e2e/infra/api/apiRequests.ts**
  * Made the `body` parameter optional for `getRequest` and `postRequest` functions.
  * Added a new `patchRequest` function to support PATCH requests.
* **e2e/logic/api/apiCalls.ts**
  * Updated API calls to use the new `graphUrl` endpoint.
  * Added new API calls for login, logout, change graph name, export graph, duplicate graph, add schema, and remove schema.
  * Removed the `data` parameter from several API calls where it was not needed.
* **e2e/logic/api/responses/LoginResponse.ts**
  * Added new response interface `AuthCredentialsResponse`.
* **e2e/logic/api/responses/addSchemaResponse.ts**
  * Added new response interface `AddSchemaResponse`.
* **e2e/logic/api/responses/changeGraphNameResponse.ts**
  * Added new response interface `ChangeGraphNameResponse`.
* **e2e/logic/api/responses/duplicateGraph.ts**
  * Added new response interface `DuplicateGraphresponse`.
* **e2e/logic/api/responses/getGraphsResponse.ts**
  * Added new response interface `GetGraphsResponse`.
* **e2e/logic/api/responses/logoutResponse.ts**
  * Added new response interface `LogoutResponse`.
* **e2e/logic/api/responses/removeSchemaResponse.ts**
  * Added new response interface `RemoveSchemaResponse`.

</details>


<details>

<summary><b>Using Gemini Code Assist</b></summary>
<br>

The full guide for Gemini Code Assist can be found on our [documentation page](https://developers.google.com/gemini-code-assist/docs/review-github-code), here are some quick tips.

<b>Invoking Gemini</b>

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either `/gemini <command>` or `@gemini-code-assist <command>`. Below is a summary of the supported commands.

Feature | Command | Description
--- | --- | ---
Code Review | `/gemini review` | Performs a code review for the current pull request in its current state.
Pull Request Summary | `/gemini summary` | Provides a summary of the current pull request in its current state.
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments.
Help | `/gemini help` | Displays a list of available commands.

<b>Customization</b>

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a `.gemini/` folder in the base of the repository. Detailed instructions can be found [here](https://developers.google.com/gemini-code-assist/docs/review-github-code).

<b>Limitations & Feedback</b>

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments to provide feedback.

</details>

<b>You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the [Gemini Code Assist IDE Extension](https://cloud.google.com/products/gemini/code-assist).</b>


[^1]: Review the [Privacy Notices](https://policies.google.com/privacy), [Generative AI Prohibited Use Policy](https://policies.google.com/terms/generative-ai/use-policy), [Terms of Service](https://policies.google.com/terms), and learn how to configure Gemini Code Assist in GitHub [here](https://developers.google.com/gemini-code-assist/docs/review-github-code). Gemini can make mistakes, so double check it and [use code with caution](https://support.google.com/legal/answer/13505487).

---

> The API calls, they must be precise,
> To ensure our tests run nice.
> With updates and tweaks,
> And careful peaks,
> We'll conquer the bugs, like mice.


state: COMMENTED
author_association: NONE
submitted_at: 2025-03-09T12:52:07Z
user: login: gemini-code-assist[bot]
body: ## Code Review
The pull request introduces several API calls and updates URL configurations. The addition of the `patchRequest` function is a valuable enhancement. However, there are some areas where improvements can be made to ensure code quality and clarity.

### Summary of Findings
* **Inconsistent API URL usage**: The API URLs are not used consistently across the application. Some functions use `urls.api.graphUrl + graphName` while others use `${urls.api.graphUrl + graphName}?query=RETURN%201`. Standardizing the URL usage will improve maintainability.
* **Missing error handling**: There is no error handling for API calls. Adding error handling will make the application more robust.
* **Inconsistent naming**: The naming of certain variables and functions is inconsistent. For example, `LogoutApiUlr` should be `LogoutApiUrl`.

### Merge Readiness
The pull request introduces important API updates, but there are several issues that need to be addressed before merging. Specifically, the inconsistent API URL usage and missing error handling should be fixed. I am unable to approve this pull request, and recommend that it not be merged until these issues are addressed and others have reviewed and approved this code.
state: CHANGES_REQUESTED
author_association: NONE
submitted_at: 2025-03-09T12:52:23Z
user: login: barakb
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-03-10T08:25:54Z

Review comments:
diff_hunk: @@ -11,53 +11,106 @@ import { CreateUsersResponse } from "./responses/createUsersResponse";
 import { DeleteUsersResponse } from "./responses/deleteUsersResponse";
 import { RunQueryResponse } from "./responses/runQueryResponse";
 import { GetUsersResponse } from "./responses/getUsersResponse";
+import { DuplicateGraphresponse } from "./responses/duplicateGraph";
+import { ChangeGraphNameResponse } from "./responses/changeGraphNameResponse";
+import { AuthCredentialsResponse } from "./responses/LoginResponse";
+import { LogoutResponse } from "./responses/logoutResponse";
+import { AddSchemaResponse } from "./responses/addSchemaResponse";
 
 export default class ApiCalls {
 
-    async addGraph(graphName: string, data?: any): Promise<AddGraphResponse> {
-        const result = await getRequest(`${urls.api.addGraphUrl + graphName}?query=RETURN%201`, data)
+    async login(): Promise<AuthCredentialsResponse> {
+        const result = await getRequest(`${urls.api.LoginApiUrl}`)
+        const jsonData = await result.json();
+        return jsonData
+    }
+
+    async logout(): Promise<LogoutResponse> {
+        const result = await postRequest(`${urls.api.LogoutApiUlr}`)
+        const jsonData = await result.json();
+        return jsonData
+    }
+
+    async addGraph(graphName: string): Promise<AddGraphResponse> {
+        const result = await getRequest(`${urls.api.graphUrl + graphName}?query=RETURN%201`)
+        const jsonData = await result.json();
+        return jsonData
+    }
+
+    async getGraphs(): Promise<GetGraphsResponse> {
+        const result = await getRequest(`${urls.api.graphUrl}`)
         const jsonData = await result.json();
         return jsonData
     }
 
     async removeGraph(graphName: string): Promise<RemoveGraphResponse> {
-        const result = await deleteRequest(urls.api.deleteGraphUrl + graphName)
+        const result = await deleteRequest(urls.api.graphUrl + graphName)
+        const jsonData = await result.json();
+        return jsonData
+    }
+
+    async changeGraphName(sourceGraph: string, destinationGraph: string): Promise<ChangeGraphNameResponse> {
+        const result = await patchRequest(urls.api.graphUrl + destinationGraph + "?sourceName=" +  sourceGraph)
+        const jsonData = await result.json();
+        return jsonData
+    }
+
+    async exportGraph(graphName: string): Promise<void> {
+        const result = await getRequest(urls.api.graphUrl + graphName + "/export")
+        const jsonData = await result.json();
+        return jsonData
+    }
+
+    async duplicateGraph(sourceGraph: string, destinationGraph: string, data?: any): Promise<DuplicateGraphresponse> {
+        const result = await postRequest(urls.api.graphUrl + destinationGraph + "?sourceName=" + sourceGraph, data)
+        const jsonData = await result.json();
+        return jsonData
+    }
+
+    async runQuery(query: string): Promise<RunQueryResponse> {
path: e2e/logic/api/apiCalls.ts
user: login: gemini-code-assist[bot]
body: ![high](https://img.shields.io/badge/priority-high-orange)

The `runQuery` function should include the query as a parameter in the URL, but it's missing. Also, it's missing error handling.

```typescript
    async runQuery(query: string): Promise<RunQueryResponse> {
        try {
            const result = await getRequest(`${urls.api.graphUrl}?query=${query}`)
            const jsonData = await result.json();
            return jsonData
        } catch (error) {
            console.error("Error running query:", error);
            throw error; // Re-throw the error to be handled by the caller
        }
    }
```
created_at: 2025-03-09T12:52:22Z
author_association: NONE
diff_hunk: @@ -1,11 +1,10 @@
 {
     "api": {
-        "addGraphUrl": "http://localhost:3000/api/graph/",
+        "graphUrl": "http://localhost:3000/api/graph/",
         "LoginApiUrl": "http://localhost:3000/api/auth/providers",
-        "deleteGraphUrl": "http://localhost:3000/api/graph/",
+        "LogoutApiUlr": "http://localhost:3000/api/auth/signout",
path: e2e/config/urls.json
user: login: gemini-code-assist[bot]
body: ![medium](https://img.shields.io/badge/priority-medium-yellow)

Typo: `LogoutApiUlr` should be `LogoutApiUrl`.

```
        "LogoutApiUrl": "http://localhost:3000/api/auth/signout",
```
created_at: 2025-03-09T12:52:22Z
author_association: NONE
diff_hunk: @@ -11,53 +11,106 @@ import { CreateUsersResponse } from "./responses/createUsersResponse";
 import { DeleteUsersResponse } from "./responses/deleteUsersResponse";
 import { RunQueryResponse } from "./responses/runQueryResponse";
 import { GetUsersResponse } from "./responses/getUsersResponse";
+import { DuplicateGraphresponse } from "./responses/duplicateGraph";
+import { ChangeGraphNameResponse } from "./responses/changeGraphNameResponse";
+import { AuthCredentialsResponse } from "./responses/LoginResponse";
+import { LogoutResponse } from "./responses/logoutResponse";
+import { AddSchemaResponse } from "./responses/addSchemaResponse";
 
 export default class ApiCalls {
 
-    async addGraph(graphName: string, data?: any): Promise<AddGraphResponse> {
-        const result = await getRequest(`${urls.api.addGraphUrl + graphName}?query=RETURN%201`, data)
+    async login(): Promise<AuthCredentialsResponse> {
+        const result = await getRequest(`${urls.api.LoginApiUrl}`)
+        const jsonData = await result.json();
+        return jsonData
+    }
+
+    async logout(): Promise<LogoutResponse> {
+        const result = await postRequest(`${urls.api.LogoutApiUlr}`)
+        const jsonData = await result.json();
+        return jsonData
+    }
+
+    async addGraph(graphName: string): Promise<AddGraphResponse> {
+        const result = await getRequest(`${urls.api.graphUrl + graphName}?query=RETURN%201`)
+        const jsonData = await result.json();
+        return jsonData
+    }
+
+    async getGraphs(): Promise<GetGraphsResponse> {
+        const result = await getRequest(`${urls.api.graphUrl}`)
         const jsonData = await result.json();
         return jsonData
     }
 
     async removeGraph(graphName: string): Promise<RemoveGraphResponse> {
-        const result = await deleteRequest(urls.api.deleteGraphUrl + graphName)
+        const result = await deleteRequest(urls.api.graphUrl + graphName)
+        const jsonData = await result.json();
+        return jsonData
+    }
+
+    async changeGraphName(sourceGraph: string, destinationGraph: string): Promise<ChangeGraphNameResponse> {
+        const result = await patchRequest(urls.api.graphUrl + destinationGraph + "?sourceName=" +  sourceGraph)
+        const jsonData = await result.json();
+        return jsonData
+    }
+
+    async exportGraph(graphName: string): Promise<void> {
+        const result = await getRequest(urls.api.graphUrl + graphName + "/export")
+        const jsonData = await result.json();
+        return jsonData
path: e2e/logic/api/apiCalls.ts
user: login: gemini-code-assist[bot]
body: ![medium](https://img.shields.io/badge/priority-medium-yellow)

It seems like the `exportGraph` function is missing error handling. Add error handling to ensure that the function behaves as expected in case of failure.

```typescript
    async exportGraph(graphName: string): Promise<void> {
        try {
            const result = await getRequest(urls.api.graphUrl + graphName + "/export")
            const jsonData = await result.json();
            return jsonData
        } catch (error) {
            console.error("Error exporting graph:", error);
            throw error; // Re-throw the error to be handled by the caller
        }
    }
```
created_at: 2025-03-09T12:52:22Z
author_association: NONE
diff_hunk: @@ -11,53 +11,106 @@ import { CreateUsersResponse } from "./responses/createUsersResponse";
 import { DeleteUsersResponse } from "./responses/deleteUsersResponse";
 import { RunQueryResponse } from "./responses/runQueryResponse";
 import { GetUsersResponse } from "./responses/getUsersResponse";
+import { DuplicateGraphresponse } from "./responses/duplicateGraph";
+import { ChangeGraphNameResponse } from "./responses/changeGraphNameResponse";
+import { AuthCredentialsResponse } from "./responses/LoginResponse";
+import { LogoutResponse } from "./responses/logoutResponse";
+import { AddSchemaResponse } from "./responses/addSchemaResponse";
 
 export default class ApiCalls {
 
-    async addGraph(graphName: string, data?: any): Promise<AddGraphResponse> {
-        const result = await getRequest(`${urls.api.addGraphUrl + graphName}?query=RETURN%201`, data)
+    async login(): Promise<AuthCredentialsResponse> {
+        const result = await getRequest(`${urls.api.LoginApiUrl}`)
+        const jsonData = await result.json();
+        return jsonData
+    }
+
+    async logout(): Promise<LogoutResponse> {
+        const result = await postRequest(`${urls.api.LogoutApiUlr}`)
+        const jsonData = await result.json();
+        return jsonData
+    }
+
+    async addGraph(graphName: string): Promise<AddGraphResponse> {
+        const result = await getRequest(`${urls.api.graphUrl + graphName}?query=RETURN%201`)
+        const jsonData = await result.json();
+        return jsonData
+    }
+
+    async getGraphs(): Promise<GetGraphsResponse> {
+        const result = await getRequest(`${urls.api.graphUrl}`)
         const jsonData = await result.json();
         return jsonData
     }
 
     async removeGraph(graphName: string): Promise<RemoveGraphResponse> {
-        const result = await deleteRequest(urls.api.deleteGraphUrl + graphName)
+        const result = await deleteRequest(urls.api.graphUrl + graphName)
+        const jsonData = await result.json();
+        return jsonData
+    }
+
+    async changeGraphName(sourceGraph: string, destinationGraph: string): Promise<ChangeGraphNameResponse> {
+        const result = await patchRequest(urls.api.graphUrl + destinationGraph + "?sourceName=" +  sourceGraph)
+        const jsonData = await result.json();
+        return jsonData
+    }
+
+    async exportGraph(graphName: string): Promise<void> {
+        const result = await getRequest(urls.api.graphUrl + graphName + "/export")
+        const jsonData = await result.json();
+        return jsonData
+    }
+
+    async duplicateGraph(sourceGraph: string, destinationGraph: string, data?: any): Promise<DuplicateGraphresponse> {
+        const result = await postRequest(urls.api.graphUrl + destinationGraph + "?sourceName=" + sourceGraph, data)
+        const jsonData = await result.json();
+        return jsonData
+    }
+
+    async runQuery(query: string): Promise<RunQueryResponse> {
+        const result = await getRequest(urls.api.graphUrl + query)
+        const jsonData = await result.json();
+        return jsonData
+    }
+
+    async modifySettingsRole(roleName: string, roleValue: string): Promise<ModifySettingsRoleResponse> {
+        const result = await postRequest(`${urls.api.settingsConfig + roleName}&value=${roleValue}`)
         const jsonData = await result.json();
         return jsonData
     }
 
-    async modifySettingsRole(roleName: string, roleValue: string, data?: any): Promise<ModifySettingsRoleResponse> {
-        const result = await postRequest(`${urls.api.settingsConfig + roleName}&value=${roleValue}`, data)
+    async getSettingsRoleValue(roleName: string): Promise<GetSettingsRoleValue> {
+        const result = await getRequest(urls.api.settingsConfig + roleName)
         const jsonData = await result.json();
         return jsonData
     }
 
-    async getSettingsRoleValue(roleName: string, data?: any): Promise<GetSettingsRoleValue> {
-        const result = await getRequest(urls.api.settingsConfig + roleName, data)
+    async getUsers(): Promise<GetUsersResponse> {
+        const result = await getRequest(urls.api.settingsUsers)
         const jsonData = await result.json();
         return jsonData
     }
 
-    async getUsers(data?: any): Promise<GetUsersResponse> {
-        const result = await getRequest(urls.api.settingsUsers, data)
+    async createUsers(): Promise<CreateUsersResponse> {
+        const result = await postRequest(urls.api.settingsUsers)
         const jsonData = await result.json();
         return jsonData
     }
 
-    async createUsers(data?: any): Promise<CreateUsersResponse> {
-        const result = await postRequest(urls.api.settingsUsers, data)
+    async deleteUsers(): Promise<DeleteUsersResponse> {
+        const result = await deleteRequest(urls.api.settingsUsers)
         const jsonData = await result.json();
         return jsonData
     }
 
-    async deleteUsers(data?: any): Promise<DeleteUsersResponse> {
-        const result = await postRequest(urls.api.settingsUsers, data)
+    async addSchema(schemaName: string): Promise<AddSchemaResponse> {
+        const result = await getRequest(`${urls.api.graphUrl + schemaName}?query=RETURN%201`)
         const jsonData = await result.json();
         return jsonData
     }
 
-    async runQuery(query: string, data?: any): Promise<RunQueryResponse> {
-        const result = await getRequest(urls.api.runQueryUrl + query, data)
+    async removeSchema(schemaName: string): Promise<RemoveGraphResponse> {
+        const result = await deleteRequest(urls.api.graphUrl + schemaName)
path: e2e/logic/api/apiCalls.ts
user: login: gemini-code-assist[bot]
body: ![medium](https://img.shields.io/badge/priority-medium-yellow)

It seems like the `removeSchema` function is missing error handling. Add error handling to ensure that the function behaves as expected in case of failure.

```typescript
    async removeSchema(schemaName: string): Promise<RemoveGraphResponse> {
        try {
            const result = await deleteRequest(urls.api.graphUrl + schemaName)
            const jsonData = await result.json();
            return jsonData
        } catch (error) {
            console.error("Error removing schema:", error);
            throw error; // Re-throw the error to be handled by the caller
        }
    }
```
created_at: 2025-03-09T12:52:23Z
author_association: NONE

PR comments:
user: login: vercel[bot]
created_at: 2025-03-09T12:52:02Z
body: [vc]: #Y5p+e0F2KjWhYfXTxD9PJZfXYyq3o7uRD+1inkZjhzw=:eyJpc01vbm9yZXBvIjp0cnVlLCJ0eXBlIjoiZ2l0aHViIiwicHJvamVjdHMiOlt7Im5hbWUiOiJmYWxrb3JkYi1icm93c2VyIiwiaW5zcGVjdG9yVXJsIjoiaHR0cHM6Ly92ZXJjZWwuY29tL2ZhbGtvcmRiL2ZhbGtvcmRiLWJyb3dzZXIvdmZjYUhUaE1IZnpSNDhSczkza291UGRiVGJxQyIsInByZXZpZXdVcmwiOiJmYWxrb3JkYi1icm93c2VyLWdpdC11cGRhdGUtYXBpY2FsbHMtZmFsa29yZGIudmVyY2VsLmFwcCIsIm5leHRDb21taXRTdGF0dXMiOiJERVBMT1lFRCIsImxpdmVGZWVkYmFjayI6eyJyZXNvbHZlZCI6MCwidW5yZXNvbHZlZCI6MCwidG90YWwiOjAsImxpbmsiOiJmYWxrb3JkYi1icm93c2VyLWdpdC11cGRhdGUtYXBpY2FsbHMtZmFsa29yZGIudmVyY2VsLmFwcCJ9LCJyb290RGlyZWN0b3J5IjpudWxsfV19
**The latest updates on your projects**. Learn more about [Vercel for Git ↗︎](https://vercel.link/github-learn-more)

| Name | Status | Preview | Comments | Updated (UTC) |
| :--- | :----- | :------ | :------- | :------ |
| **falkordb-browser** | ✅ Ready ([Inspect](https://vercel.com/falkordb/falkordb-browser/vfcaHThMHfzR48Rs93kouPdbTbqC)) | [Visit Preview](https://falkordb-browser-git-update-apicalls-falkordb.vercel.app) | 💬 [**Add feedback**](https://vercel.live/open-feedback/falkordb-browser-git-update-apicalls-falkordb.vercel.app?via=pr-comment-feedback-link) | Mar 9, 2025 1:41pm |


author_association: NONE
user: login: coderabbitai[bot]
created_at: 2025-03-09T12:52:05Z
body: <!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- This is an auto-generated comment: skip review by coderabbit.ai -->

> [!IMPORTANT]
> ## Review skipped
> 
> Auto reviews are disabled on base/target branches other than the default branch.
> 
> 
> 
> Please check the settings in the CodeRabbit UI or the `.coderabbit.yaml` file in this repository. To trigger a single review, invoke the `@coderabbitai review` command.
> 
> You can disable this status message by setting the `reviews.review_status` to `false` in the CodeRabbit configuration file.

<!-- end of auto-generated comment: skip review by coderabbit.ai -->
<!-- tips_start -->

---

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=FalkorDB/falkordb-browser&utm_content=734):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Generate unit testing code for this file.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai generate unit testing code for this file.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and generate unit testing code.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->
author_association: CONTRIBUTOR