From 079e199039d3489e6e0228477e482aa28afe103e Mon Sep 17 00:00:00 2001 From: Riley Grant Date: Fri, 27 Oct 2023 12:23:00 -0500 Subject: [PATCH] fixup: graphql cleanup --- graphql-api/src/config.ts | 4 +--- graphql-api/src/graphql/graphql-api.ts | 18 +++++++++--------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/graphql-api/src/config.ts b/graphql-api/src/config.ts index ae17e8ca7..44a46003a 100644 --- a/graphql-api/src/config.ts +++ b/graphql-api/src/config.ts @@ -28,9 +28,7 @@ const config: Record = { ELASTICSEARCH_REQUEST_TIMEOUT: JSON.parse(env.ELASTICSEARCH_REQUEST_TIMEOUT || '30') * 1000, // Cache CACHE_REDIS_URL: env.CACHE_REDIS_URL, - // FIXME: revert this, do not merge to main - // CACHE_REQUEST_TIMEOUT: JSON.parse(env.CACHE_REQUEST_TIMEOUT || '15') * 1000, - CACHE_REQUEST_TIMEOUT: JSON.parse(env.CACHE_REQUEST_TIMEOUT || '15') * 1, + CACHE_REQUEST_TIMEOUT: JSON.parse(env.CACHE_REQUEST_TIMEOUT || '15') * 1000, // Web server PORT: JSON.parse(env.PORT || '8000'), TRUST_PROXY: parseProxyConfig(env.TRUST_PROXY || 'false'), diff --git a/graphql-api/src/graphql/graphql-api.ts b/graphql-api/src/graphql/graphql-api.ts index 495aaa7a9..48ea9e1ee 100644 --- a/graphql-api/src/graphql/graphql-api.ts +++ b/graphql-api/src/graphql/graphql-api.ts @@ -7,7 +7,7 @@ import { isHttpError } from 'http-errors' import config from '../config' import logger from '../logger' -// import { applyRateLimits } from './rate-limiting' +import { applyRateLimits } from './rate-limiting' import schema from './schema' const customParseFn = (...args: Parameters) => { @@ -174,14 +174,14 @@ const graphQLApi = ({ context }: any) => } // Apply rate limit before executing query. - // try { - // await applyRateLimits(request) - // } catch (error) { - // // Throw GraphQLErrors from GraphQL execution. - // // Errors must be wrapped in GraphQLError for customFormatErrorFn to handle them correctly. - // // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. - // throw new GraphQLError(error.message, undefined, undefined, undefined, undefined, error) - // } + try { + await applyRateLimits(request) + } catch (error) { + // Throw GraphQLErrors from GraphQL execution. + // Errors must be wrapped in GraphQLError for customFormatErrorFn to handle them correctly. + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. + throw new GraphQLError(error.message, undefined, undefined, undefined, undefined, error) + } return execute(args) },