Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade to graphqlws #1424

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
"@ory/client": "^0.0.1-alpha.123",
"@ory/kratos-client": "^0.10.1",
"ajv": "^8.10.0",
"apollo-server-core": "^3.8.2",
"apollo-server-core": "^3.10.0",
"apollo-server-errors": "^3.3.1",
"apollo-server-express": "^3.8.2",
"apollo-server-express": "^3.10.0",
"axios": "^0.27.2",
"bip32": "^3.0.1",
"bitcoin-core-ts": "^3.0.3",
Expand All @@ -56,16 +56,17 @@
"csv-writer": "^1.6.0",
"dedent": "^0.7.0",
"dotenv": "^16.0.0",
"express": "^4.17.2",
"express": "^4.18.1",
"express-jwt": "^7.7.5",
"firebase-admin": "^11.0.0",
"google-protobuf": "^3.19.4",
"graphql": "^16.3.0",
"graphql-middleware": "^6.1.29",
"graphql": "^16.5.0",
"graphql-middleware": "^6.1.32",
"graphql-redis-subscriptions": "^2.4.2",
"graphql-relay": "^0.10.0",
"graphql-shield": "^7.5.0",
"graphql-tools": "^8.2.12",
"graphql-tools": "^8.3.1",
"graphql-ws": "^5.9.1",
"gt3-server-node-express-sdk": "https://github.com/GaloyMoney/gt3-server-node-express-bypass#master",
"helmet": "^5.1.0",
"i18n": "^0.15.0",
Expand Down Expand Up @@ -96,7 +97,8 @@
"redlock": "^5.0.0-beta.2",
"subscriptions-transport-ws": "^0.11.0",
"twilio": "^3.77.2",
"uuid-by-string": "^3.0.4"
"uuid-by-string": "^3.0.4",
"ws": "^8.8.1"
},
"devDependencies": {
"@apollo/client": "^3.6.6",
Expand Down Expand Up @@ -154,8 +156,7 @@
"ts-node-dev": "^2.0.0",
"tsconfig-paths": "^4.0.0",
"tscpaths": "^0.0.9",
"typescript": "^4.7.3",
"ws": "^8.7.0"
"typescript": "^4.7.3"
},
"resolutions": {
"**/**/ws": ">=7.4.6",
Expand Down
7 changes: 5 additions & 2 deletions src/domain/users-ips/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
export const parseIps = (ips: undefined | string | string[]): IpAddress | undefined => {
export const parseIps = (
ips: undefined | string | string[] | unknown,
): IpAddress | undefined => {
if (!ips) return undefined

if (Array.isArray(ips) && ips.length) {
return toIpAddress(ips[0])
if (typeof ips[0] === "string") return toIpAddress(ips[0])
return undefined
}

if (typeof ips === "string") {
Expand Down
6 changes: 4 additions & 2 deletions src/servers/graphql-admin-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { GALOY_ADMIN_PORT } from "@config"

import { gqlAdminSchema } from "../graphql"

import { startApolloServer, isAuthenticated, isEditor } from "./graphql-server"
import { isAuthenticated, isEditor, serverPath } from "./helper"

dotenv.config()

Expand Down Expand Up @@ -42,7 +42,9 @@ export async function startApolloServerForAdminSchema() {
)

const schema = applyMiddleware(gqlAdminSchema, permissions)
return startApolloServer({ schema, port: GALOY_ADMIN_PORT, type: "admin" })

const { startApolloServer } = await import(serverPath)
return startApolloServer({ schema, port: GALOY_ADMIN_PORT })
}

if (require.main === module) {
Expand Down
5 changes: 4 additions & 1 deletion src/servers/graphql-main-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { GALOY_API_PORT } from "@config"

import { gqlMainSchema } from "../graphql"

import { isAuthenticated, startApolloServer } from "./graphql-server"
import { walletIdMiddleware } from "./middlewares/wallet-id"
import { isAuthenticated, serverPath } from "./helper"

const graphqlLogger = baseLogger.child({ module: "graphql" })

Expand Down Expand Up @@ -60,6 +60,9 @@ export async function startApolloServerForCoreSchema() {
)

const schema = applyMiddleware(gqlMainSchema, permissions, walletIdMiddleware)

const { startApolloServer } = await import(serverPath)

return startApolloServer({
schema,
port: GALOY_API_PORT,
Expand Down
Loading