Skip to content

Commit 6241d3d

Browse files
committed
attempt to fix graphql test
1 parent 8996c1e commit 6241d3d

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

packages/datadog-plugin-graphql/test/tools/signature.spec.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const assert = require('node:assert/strict')
44
const Module = require('node:module')
5+
const path = require('node:path')
56
const { inspect } = require('node:util')
67

78
const { describe, it, before, after } = require('mocha')
@@ -16,9 +17,14 @@ const sinon = require('sinon')
1617
const loadableModule = /** @type {LoadableModule} */ (Module)
1718

1819
// The transforms module reads `globalThis[Symbol.for('dd-trace')].graphql_*`
19-
// at require time, so populate them before requiring the tools.
20-
const visitor = require('graphql/language/visitor')
21-
const printer = require('graphql/language/printer')
20+
// at require time, so populate them before requiring the tools. Requiring by
21+
// absolute path (rather than the `graphql/language/visitor` subpath) bypasses
22+
// graphql's package.json `exports` map, so this always gets the mutable CJS
23+
// module instead of the read-only ES module namespace object that the
24+
// `module-sync` export condition resolves to on Node >=22.
25+
const graphqlRoot = path.dirname(require.resolve('graphql'))
26+
const visitor = require(path.join(graphqlRoot, 'language/visitor.js'))
27+
const printer = require(path.join(graphqlRoot, 'language/printer.js'))
2228
const ddGlobal = globalThis[Symbol.for('dd-trace')]
2329
ddGlobal.graphql_visitor = visitor
2430
ddGlobal.graphql_printer = printer

0 commit comments

Comments
 (0)