diff --git a/api/package.json b/api/package.json index 0cdc22f5..24e77cad 100644 --- a/api/package.json +++ b/api/package.json @@ -40,7 +40,6 @@ "express-prom-bundle": "^7.0.0", "graphql": "^16.8.1", "graphql-middleware": "^6.1.35", - "graphql-playground-html": "^1.6.30", "graphql-playground-middleware-express": "^1.7.23", "graphql-request": "^7.0.1", "json-stringify-deterministic": "^1.0.12", diff --git a/api/pnpm-lock.yaml b/api/pnpm-lock.yaml index 17b84754..739b6e1a 100644 --- a/api/pnpm-lock.yaml +++ b/api/pnpm-lock.yaml @@ -68,9 +68,6 @@ importers: graphql-middleware: specifier: ^6.1.35 version: 6.1.35(graphql@16.9.0) - graphql-playground-html: - specifier: ^1.6.30 - version: 1.6.30 graphql-playground-middleware-express: specifier: ^1.7.23 version: 1.7.23(express@4.19.2) diff --git a/api/src/app.ts b/api/src/app.ts index 2cfccce0..0fdfb65d 100644 --- a/api/src/app.ts +++ b/api/src/app.ts @@ -4,10 +4,10 @@ import bodyParser from 'body-parser'; import type { Express } from 'express'; import express from 'express'; import promBundle from 'express-prom-bundle'; -import { renderPlaygroundPage } from 'graphql-playground-html'; import { dependencies } from '../package.json'; import prisma from './database'; +import { renderGraphqlPlayground } from './graphql/playground'; import { getChildLogger } from './logger'; import register from './metrics'; @@ -92,14 +92,7 @@ export const createApp = (): { app: Express; router: express.Router } => { const basePath = process.env.BASE_PATH === '/' ? '' : process.env.BASE_PATH || ''; const endpoint = `${basePath}${req.params.driveId !== undefined ? `/d/${req.params.driveId}` : '/drives'}`; - res.send( - renderPlaygroundPage({ - endpoint, - settings: { - 'request.credentials': 'include' - } - }) - ); + res.send(renderGraphqlPlayground(endpoint)); }); // Hooks diff --git a/api/src/graphql/playground.ts b/api/src/graphql/playground.ts new file mode 100644 index 00000000..f51da43a --- /dev/null +++ b/api/src/graphql/playground.ts @@ -0,0 +1,63 @@ +export function renderGraphqlPlayground( + url: string, + headers: Record = {} +): string { + return ` + + + GraphiQL + + + + + + + + + + +
Loading...
+ + + `; +} diff --git a/api/src/modules/document-drive/utils.ts b/api/src/modules/document-drive/utils.ts index d2051afc..4851ca54 100644 --- a/api/src/modules/document-drive/utils.ts +++ b/api/src/modules/document-drive/utils.ts @@ -1,6 +1,8 @@ import { GraphQLError } from 'graphql'; import { Context } from '../../graphql/server'; +const isDevelopment = process.env.NODE_ENV === 'development'; + export function isAdmin(user: string) { const { ADMIN_USERS } = process.env; return ADMIN_USERS?.split(',') @@ -9,6 +11,9 @@ export function isAdmin(user: string) { } export async function checkUserIsAdmin(ctx: Context) { + if (isDevelopment) { + return; + } const { revokedAt, createdBy, referenceExpiryDate } = await ctx.getSession(); if ( process.env.ADMIN_USERS !== undefined && ( diff --git a/api/src/modules/system/user/model.ts b/api/src/modules/system/user/model.ts index 2476d52c..d2128eba 100644 --- a/api/src/modules/system/user/model.ts +++ b/api/src/modules/system/user/model.ts @@ -23,7 +23,7 @@ export function getUserCrud(prisma: Prisma.TransactionClient) { update: {}, create: { ...user } }); - logger.error('Upserted user', upsertedUser); + logger.info('Upserted user', upsertedUser); return upsertedUser; } };