Skip to content

Commit

Permalink
fixup: graphql cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rileyhgrant committed Oct 27, 2023
1 parent 787a9d4 commit 079e199
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
4 changes: 1 addition & 3 deletions graphql-api/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ const config: Record<string, any> = {
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'),
Expand Down
18 changes: 9 additions & 9 deletions graphql-api/src/graphql/graphql-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof parse>) => {
Expand Down Expand Up @@ -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)
},
Expand Down

0 comments on commit 079e199

Please sign in to comment.