Use Fastify Mercurius and GraphQL contracts
Some checks are pending
Build Docker Image / build (push) Waiting to run

This commit is contained in:
Ruslan Bakiev
2026-06-01 00:25:27 +05:00
parent 430cb1cff6
commit 3229a527cc
5 changed files with 1122 additions and 1852 deletions

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "graphql-contracts"]
path = graphql-contracts
url = git@gitea.dsrptlab.com:optovia/geo-graphql-contracts.git

1
graphql-contracts Submodule

Submodule graphql-contracts added at f92ac6e367

2925
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -8,16 +8,14 @@
"dev": "tsx --watch src/index.ts"
},
"dependencies": {
"@apollo/server": "^4.11.3",
"@fastify/cors": "^11.2.0",
"@sentry/node": "^9.5.0",
"arangojs": "^9.2.0",
"cors": "^2.8.5",
"express": "^5.0.1",
"h3-js": "^4.2.1"
"fastify": "^5.8.5",
"h3-js": "^4.2.1",
"mercurius": "^16.9.0"
},
"devDependencies": {
"@types/cors": "^2.8.17",
"@types/express": "^5.0.0",
"@types/node": "^22.13.0",
"tsx": "^4.19.3",
"typescript": "^5.7.3"

View File

@@ -1,22 +1,21 @@
import express from 'express'
import cors from 'cors'
import { ApolloServer } from '@apollo/server'
import { expressMiddleware } from '@apollo/server/express4'
import { typeDefs, resolvers } from './schema.js'
import Fastify from "fastify";
import cors from "@fastify/cors";
import mercurius from "mercurius";
import { typeDefs, resolvers } from "./schema.js";
const PORT = parseInt(process.env.PORT || '8000', 10)
const PORT = Number.parseInt(process.env.PORT || "8000", 10);
const app = express()
app.use(cors({ origin: ['https://optovia.ru'], credentials: true }))
const app = Fastify();
await app.register(cors, { origin: ["https://optovia.ru"], credentials: true });
await app.register(mercurius, {
schema: typeDefs,
resolvers,
path: "/graphql/public",
graphiql: true,
});
const server = new ApolloServer({ typeDefs, resolvers, introspection: true })
await server.start()
app.get("/health", async () => ({ status: "ok" }));
app.use('/graphql/public', express.json(), expressMiddleware(server) as unknown as express.RequestHandler)
app.get('/health', (_, res) => { res.json({ status: 'ok' }) })
app.listen(PORT, '0.0.0.0', () => {
console.log(`Geo server ready on port ${PORT}`)
console.log(` /graphql/public - public (no auth)`)
})
await app.listen({ port: PORT, host: "0.0.0.0" });
console.log(`Geo server ready on port ${PORT}`);
console.log(` /graphql/public - public (no auth)`);