diff --git a/apps/backend/package.json b/apps/backend/package.json index a2b34ade99b8951186d267a773e576f05beff200..345144eedf51dc23d9ef9792106b9cedc22aaea7 100644 --- a/apps/backend/package.json +++ b/apps/backend/package.json @@ -5,7 +5,7 @@ "author": "", "private": true, "license": "UNLICENSED", - "packageManager": "yarn@4.4.0", + "packageManager": "yarn@4.4.1", "scripts": { "build": "nest build", "clean": "rimraf dist", diff --git a/apps/eventListener/package.json b/apps/eventListener/package.json index e6865f165ce070d0dfd69f316226008fdf7e0019..ba82610280c7f9b22648ce15fb2e060a09947876 100644 --- a/apps/eventListener/package.json +++ b/apps/eventListener/package.json @@ -1,7 +1,7 @@ { "name": "@holi/moderation-event-listener", "main": "dist/index.js", - "packageManager": "yarn@4.4.0", + "packageManager": "yarn@4.4.1", "dependencies": { "@google-cloud/functions-framework": "3.4.2", "@ory/client": "1.14.2" diff --git a/apps/frontend/package.json b/apps/frontend/package.json index 8608be2fc5757db177960df6e8cd7b4005eb9d18..c90915c561020661e3213e2a0aa66c47c73a51e5 100644 --- a/apps/frontend/package.json +++ b/apps/frontend/package.json @@ -3,7 +3,7 @@ "private": true, "version": "0.1.0", "type": "module", - "packageManager": "yarn@4.4.0", + "packageManager": "yarn@4.4.1", "scripts": { "dev": "vite", "build": "yarn clean && vite build", diff --git a/mprocs-start-fake.ts b/mprocs-start-fake.ts index 23ef583f2f382815c3ca5e4efe8e138d8f0003b3..728bb922a0d6f5ddb506473b087f5d2b833bd3b0 100644 --- a/mprocs-start-fake.ts +++ b/mprocs-start-fake.ts @@ -1,7 +1,7 @@ import type { IncomingMessage, ServerResponse } from 'http' import { createServer } from 'http' -import type { GraphQLSchema } from 'graphql' +import type { IntrospectionQuery } from 'graphql' import { introspectionFromSchema, parse as parseGql } from 'graphql' import { NestFactory } from '@nestjs/core' import { GraphQLSchemaBuilderModule, GraphQLSchemaFactory } from '@nestjs/graphql' @@ -9,15 +9,14 @@ import { ReportsResolver } from '@holi/moderation-backend/dist/src/reports/resol import { Pagination, Success } from '@holi/moderation-backend/dist/src/graphql/commonSchema' import { AuthResolver } from '@holi/moderation-backend/dist/src/auth/resolver' -async function gqlSchemaFrom(types: Array<any>): Promise<GraphQLSchema> { +async function introspectionSchemaFrom(types: Array<any>): Promise<IntrospectionQuery> { const app = await NestFactory.create(GraphQLSchemaBuilderModule) await app.init() - const gqlSchemaFactory = app.get(GraphQLSchemaFactory) const schema = await gqlSchemaFactory.create(types) - await app.close() - return schema + + return introspectionFromSchema(schema) } const buildListener = @@ -29,6 +28,8 @@ const buildListener = }) req.on('end', () => { + if (!body) return res.end() + const parsedBody = JSON.parse(body) const query = parsedBody.query const operationName = parsedBody.operationName @@ -43,7 +44,7 @@ const buildListener = if ('IntrospectionQuery' === inferredOperationName) { res.writeHead(200, { 'Content-Type': 'application/json' }) - res.end(JSON.stringify(introspectionResponse)) + res.end(JSON.stringify({ data: introspectionResponse })) } if ('ReportContent' === inferredOperationName) { res.writeHead(200, { 'Content-Type': 'application/json' }) @@ -59,12 +60,13 @@ const COMMON_TYPES = [Pagination, Success] const RESOLVERS_TO_FAKE = [ReportsResolver] -void gqlSchemaFrom([...RESOLVERS_TO_FAKE, ...COMMON_RESOLVERS, ...COMMON_TYPES]).then((schema) => { - const introspectionResponse = { - data: { - ...introspectionFromSchema(schema), - }, - } +void (async () => { + const introspectionResponse = await introspectionSchemaFrom([ + ...RESOLVERS_TO_FAKE, + ...COMMON_RESOLVERS, + ...COMMON_TYPES, + ]) + const createReportResponse = { // "moderation_" relates to the unified-api mesh prefix name for the mutation moderation_createReport: { @@ -77,4 +79,4 @@ void gqlSchemaFrom([...RESOLVERS_TO_FAKE, ...COMMON_RESOLVERS, ...COMMON_TYPES]) server.listen(PORT, () => { console.log(`Fake backend running on http://localhost:${PORT}/graphql`) }) -}) +})() diff --git a/package.json b/package.json index 9678ef871e80d3fb55a0eb3989431b6f16d681f0..72779c5d22f7655ef659d8c5c74abcc57bdf12d2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@holi/moderation", "private": true, - "packageManager": "yarn@4.4.0", + "packageManager": "yarn@4.4.1", "workspaces": [ "apps/backend", "apps/frontend",