Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(graphql-server): Improve GraphQL API performance by not accessing project config in makeMergedSchema #9032

Merged
merged 1 commit into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/graphql-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"@graphql-tools/utils": "10.0.1",
"@opentelemetry/api": "1.4.1",
"@redwoodjs/api": "6.0.5",
"@redwoodjs/project-config": "6.0.5",
"core-js": "3.31.1",
"graphql": "16.7.1",
"graphql-scalars": "1.22.2",
Expand All @@ -48,6 +47,7 @@
"@babel/core": "7.22.9",
"@envelop/testing": "6.0.0",
"@envelop/types": "4.0.0",
"@redwoodjs/project-config": "6.0.5",
"@redwoodjs/realtime": "6.0.5",
"@types/jsonwebtoken": "9.0.2",
"@types/lodash": "4.14.195",
Expand Down
15 changes: 1 addition & 14 deletions packages/graphql-server/src/makeMergedSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import type {
} from 'graphql'
import { merge, omitBy } from 'lodash'

import { getConfig } from '@redwoodjs/project-config'

import type { RedwoodDirective } from './plugins/useRedwoodDirective'
import * as rootGqlSchema from './rootSchema'
import type { RedwoodSubscription } from './subscriptions/makeSubscriptions'
Expand Down Expand Up @@ -104,22 +102,11 @@ const mapFieldsToService = ({
context: unknown,
info: unknown
) => {
// In serverless deploys like Netilfy and Vercel, the redwood.toml file may not be present,
// so we need to try-catch the attempt here to read it
let experimentalOpenTelemetryEnabled = false

try {
experimentalOpenTelemetryEnabled =
getConfig().experimental.opentelemetry.enabled
} catch (e) {
// Swallow the error for now
}

const captureResolvers =
// @ts-expect-error context is unknown
context && context['OPEN_TELEMETRY_GRAPHQL'] !== undefined

if (experimentalOpenTelemetryEnabled && captureResolvers) {
if (captureResolvers) {
return wrapWithOpenTelemetry(
services[name],
args,
Expand Down
Loading