-
Notifications
You must be signed in to change notification settings - Fork 41
Closed
Description
Hi. I have my codebase in Typescript and had queryComplexity
setup in my project some time ago. It worked well when my codebase was transpiled to commonjs and I was targetting ES2017
But recently I made the move to use ES2020
with Node.js modules (type:"module" in
package.json`) and I get this error:
This is how I am importing (as in the README):
import queryComplexity, { directiveEstimator, simpleEstimator } from 'graphql-query-complexity';
And my validationRules look like this (from the README):
validationRules: [
queryComplexity({
estimators: [
directiveEstimator({
name: 'complexity'
}),
simpleEstimator({
defaultComplexity: 1
})
],
maximumComplexity: 500,
variables: variables,
onComplete: (complexity: number) => {
console.log('Query Complexity:', complexity);
},
createError: (max: number, actual: number) => {
return new GraphQLError(`Query is too complex: ${actual}. Maximum allowed complexity: ${max}`);
}
})
]
My old TSConfig (which worked):
{
"compileOnSave": true,
"compilerOptions": {
"target": "ES2017",
"module": "commonjs",
"declaration": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"moduleResolution": "node",
"esModuleInterop": true,
"incremental": true,
"tsBuildInfoFile": "./dist/tsbuildinfo",
"alwaysStrict": true,
"skipLibCheck": true,
"noImplicitAny": false,
"noUnusedLocals": true,
"removeComments": true,
"preserveConstEnums": true,
"allowSyntheticDefaultImports": true,
"outDir": "dist",
"rootDir": "src",
"declarationMap": true,
"sourceMap": true,
"strict": true,
"noEmitOnError": true,
"lib": ["ES2017"]
},
"include": ["./src/**/*"],
"exclude": ["node_modules", "**/*.spec.ts", "**/*.d.ts"]
}
My new TSConfig which does not work:
{
"compileOnSave": true,
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"declaration": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"moduleResolution": "node",
"esModuleInterop": true,
"incremental": true,
"tsBuildInfoFile": "./dist/tsbuildinfo",
"alwaysStrict": true,
"skipLibCheck": true,
"noImplicitAny": false,
"noUnusedLocals": true,
"removeComments": true,
"preserveConstEnums": true,
"allowSyntheticDefaultImports": true,
"outDir": "dist",
"rootDir": "src",
"declarationMap": true,
"sourceMap": true,
"strict": true,
"noEmitOnError": true,
"lib": ["ES2020"]
},
"include": ["./src/**/*"],
"exclude": ["node_modules", "**/*.spec.ts", "**/*.d.ts"]
}
PS: All other libraries work except this since I have esModuleInterop
set.
Any ideas what I might be doing wrong? Thanks.
Metadata
Metadata
Assignees
Labels
No labels