From 3ff147fbcb5ad5bdd16ff21244cc85f29602e715 Mon Sep 17 00:00:00 2001 From: wentokay Date: Wed, 15 Mar 2023 20:28:37 -0700 Subject: [PATCH 1/2] fix eslint issue --- backend/native/backend-ws/package.json | 5 ++++- backend/native/backend-ws/tsconfig.json | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/backend/native/backend-ws/package.json b/backend/native/backend-ws/package.json index e49912521..f133a35dd 100644 --- a/backend/native/backend-ws/package.json +++ b/backend/native/backend-ws/package.json @@ -21,9 +21,12 @@ "build": "esbuild ./src/index.js --bundle --platform=node --outfile=dist/index.js", "start": "npm run build && node dist/index.js", "zeus-ws": "npx graphql-zeus http://localhost:8113/v1/graphql ./src --header=x-hasura-admin-secret:myadminsecretkey --header=x-hasura-role:chat --subscriptions graphql-ws", - "zeus": "npx graphql-zeus http://localhost:8113/v1/graphql ./src --header=x-hasura-admin-secret:myadminsecretkey --header=x-hasura-role:chat --subscriptions" + "zeus": "npx graphql-zeus http://localhost:8113/v1/graphql ./src --header=x-hasura-admin-secret:myadminsecretkey --header=x-hasura-role:chat --subscriptions", + "lint": "eslint ./src --ext .js,.jsx,.ts,.tsx --cache", + "lint:fix": "yarn run lint --fix" }, "devDependencies": { + "eslint-config-custom": "*", "esbuild": "^0.17.11" } } diff --git a/backend/native/backend-ws/tsconfig.json b/backend/native/backend-ws/tsconfig.json index e8215cf65..91c121a0e 100644 --- a/backend/native/backend-ws/tsconfig.json +++ b/backend/native/backend-ws/tsconfig.json @@ -10,6 +10,5 @@ "noImplicitAny": true, "esModuleInterop": true, "resolveJsonModule": true - }, - "files": ["src/index.ts"] + } } From 19a06516fcdf2800ea6351ee99ea55eab91e335d Mon Sep 17 00:00:00 2001 From: wentokay Date: Wed, 15 Mar 2023 20:30:15 -0700 Subject: [PATCH 2/2] add operationName to queries --- backend/native/backend-ws/src/db/users.ts | 28 +++++++++++-------- backend/native/backpack-api/src/db/users.ts | 27 ++++++++++-------- .../src/db/collection_messages.ts | 25 +++++++++-------- 3 files changed, 47 insertions(+), 33 deletions(-) diff --git a/backend/native/backend-ws/src/db/users.ts b/backend/native/backend-ws/src/db/users.ts index ecf2805a3..ca7386ef8 100644 --- a/backend/native/backend-ws/src/db/users.ts +++ b/backend/native/backend-ws/src/db/users.ts @@ -1,4 +1,5 @@ import { Chain } from "@coral-xyz/zeus"; + import { AUTH_HASURA_URL, AUTH_JWT } from "../config"; const chain = Chain(AUTH_HASURA_URL, { @@ -10,16 +11,21 @@ const chain = Chain(AUTH_HASURA_URL, { export const getUsers = async ( userIds: string[] ): Promise<{ id: string; username: string }[]> => { - const response = await chain("query")({ - auth_users: [ - { - where: { id: { _in: userIds } }, - }, - { - id: true, - username: true, - }, - ], - }); + const response = await chain("query")( + { + auth_users: [ + { + where: { id: { _in: userIds } }, + }, + { + id: true, + username: true, + }, + ], + }, + { + operationName: "getUsers", + } + ); return response.auth_users || []; }; diff --git a/backend/native/backpack-api/src/db/users.ts b/backend/native/backpack-api/src/db/users.ts index a1d951d04..19ea1f6bf 100644 --- a/backend/native/backpack-api/src/db/users.ts +++ b/backend/native/backpack-api/src/db/users.ts @@ -21,17 +21,22 @@ export const getUsersMetadata = async ( id: unknown; }[] > => { - const response = await chain("query")({ - auth_users: [ - { - where: { id: { _in: userIds } }, - }, - { - id: true, - username: true, - }, - ], - }); + const response = await chain("query")( + { + auth_users: [ + { + where: { id: { _in: userIds } }, + }, + { + id: true, + username: true, + }, + ], + }, + { + operationName: "getUsersMetadata", + } + ); return response.auth_users.map((x) => ({ username: x.username, id: x.id, diff --git a/backend/native/notifications-worker/src/db/collection_messages.ts b/backend/native/notifications-worker/src/db/collection_messages.ts index 53bcaa9f0..4046f4c71 100644 --- a/backend/native/notifications-worker/src/db/collection_messages.ts +++ b/backend/native/notifications-worker/src/db/collection_messages.ts @@ -9,16 +9,19 @@ const chain = Chain(AUTH_HASURA_URL, { }); export const getLatestReadMessage = async (uuid: string, room: string) => { - const response = await chain("query")({ - auth_collection_messages_by_pk: [ - { - collection_id: room, - uuid: uuid, - }, - { - last_read_message_id: true, - }, - ], - }); + const response = await chain("query")( + { + auth_collection_messages_by_pk: [ + { + collection_id: room, + uuid: uuid, + }, + { + last_read_message_id: true, + }, + ], + }, + { operationName: "getLatestReadMessage" } + ); return response.auth_collection_messages_by_pk.last_read_message_id; };