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

GraphQL plugin fails to load TS config file graphql.config.ts #732

Open
arkandias opened this issue Jan 13, 2025 · 0 comments
Open

GraphQL plugin fails to load TS config file graphql.config.ts #732

arkandias opened this issue Jan 13, 2025 · 0 comments

Comments

@arkandias
Copy link

arkandias commented Jan 13, 2025

I followed the doc to use a TS file as a config file. My configuration:

  • WebStorm 2024.3.1.1
  • node v20.18.1
  • ts-node v10.9.2 (installed in dev dependencies)
  • graphql.config.ts below
  • tsconfig.json below (which includes "ts-node": { "esm": true })
  • package.json specifies "type": "module"

GraphQL plugin raises a "Failed to evaluate config" error (see the stack trace below).

Note that if I rename graphql.config.ts to graphql.config.js, the plugin successfully loads the configuration.

// graphql.config.ts
const config = {
  schema: "schema.graphql",
  documents: "**/*.graphql"
};

export default config;
// tsconfig.json
{
  "compilerOptions": {
    /* Type Checking */
    "strict": true,
    "noFallthroughCasesInSwitch": true,
    "noImplicitOverride": true,
    "noImplicitReturns": true,
    "noPropertyAccessFromIndexSignature": true,
    "noUncheckedIndexedAccess": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,

    /* Language and Environment */
    "target": "ES2022",
    "lib": ["ES2022"],
    "moduleDetection": "force",

    /* Module */
    "module": "ESNext",
    "moduleResolution": "bundler",
    "allowImportingTsExtensions": true,
    "noUncheckedSideEffectImports": true,
    "baseUrl": "./",

    /* Emit */
    "noEmit": true,

    /* Interop Constraints */
    "isolatedModules": true,
    "verbatimModuleSyntax": true,

    /* Projects */
    "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",

    /* Completeness */
    "skipLibCheck": true
  },
  // For GraphQL plugin
  "ts-node": {
    "esm": true
  },
  "include": ["*.ts"]
}
// config-error.txt
java.lang.Throwable: (node:91605) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("ts-node/esm", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)
ReferenceError: exports is not defined in ES module scope
    at graphql.config.ts:2:23



	at com.intellij.lang.jsgraphql.javascript.config.GraphQLJavaScriptConfigLoader.completeExceptionally(GraphQLJavaScriptConfigLoader.kt:98)
	at com.intellij.lang.jsgraphql.javascript.config.GraphQLJavaScriptConfigLoader.load(GraphQLJavaScriptConfigLoader.kt:71)
	at com.intellij.lang.jsgraphql.ide.config.loader.GraphQLConfigLoader.readJs(GraphQLConfigLoader.kt:171)
	at com.intellij.lang.jsgraphql.ide.config.loader.GraphQLConfigLoader.readData(GraphQLConfigLoader.kt:130)
	at com.intellij.lang.jsgraphql.ide.config.loader.GraphQLConfigLoader.load(GraphQLConfigLoader.kt:29)
	at com.intellij.lang.jsgraphql.ide.config.GraphQLConfigProvider.reload(GraphQLConfigProvider.kt:409)
	at com.intellij.lang.jsgraphql.ide.config.GraphQLConfigProvider.access$reload(GraphQLConfigProvider.kt:67)
	at com.intellij.lang.jsgraphql.ide.config.GraphQLConfigProvider$4$1.invokeSuspend(GraphQLConfigProvider.kt:138)
	at com.intellij.lang.jsgraphql.ide.config.GraphQLConfigProvider$4$1.invoke(GraphQLConfigProvider.kt)
	at com.intellij.lang.jsgraphql.ide.config.GraphQLConfigProvider$4$1.invoke(GraphQLConfigProvider.kt)
	at kotlinx.coroutines.flow.FlowKt__MergeKt$mapLatest$1.invokeSuspend(Merge.kt:213)
	at kotlinx.coroutines.flow.FlowKt__MergeKt$mapLatest$1.invoke(Merge.kt)
	at kotlinx.coroutines.flow.FlowKt__MergeKt$mapLatest$1.invoke(Merge.kt)
	at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invokeSuspend(Merge.kt:30)
	at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invoke(Merge.kt)
	at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invoke(Merge.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startCoroutineUndispatched(Undispatched.kt:27)
	at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:90)
	at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:123)
	at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:52)
	at kotlinx.coroutines.BuildersKt.launch(Unknown Source)
	at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:43)
	at kotlinx.coroutines.BuildersKt.launch$default(Unknown Source)
	at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1.emit(Merge.kt:29)
	at kotlinx.coroutines.flow.internal.FlowValueWrapperInternalKt.emitInternal(FlowValueWrapperInternal.kt:39)
	at kotlinx.coroutines.flow.FlowKt__DelayKt$debounceInternal$1$3$1.invokeSuspend(Delay.kt:226)
	at kotlinx.coroutines.flow.FlowKt__DelayKt$debounceInternal$1$3$1.invoke(Delay.kt)
	at kotlinx.coroutines.flow.FlowKt__DelayKt$debounceInternal$1$3$1.invoke(Delay.kt)
	at kotlinx.coroutines.selects.SelectImplementation$ClauseData.invokeBlock(Select.kt:828)
	at kotlinx.coroutines.selects.SelectImplementation$complete$3.invokeSuspend(Select.kt:701)
	at kotlinx.coroutines.selects.SelectImplementation$complete$3.invoke(Select.kt)
	at kotlinx.coroutines.selects.SelectImplementation$complete$3.invoke(Select.kt)
	at kotlinx.coroutines.flow.internal.FlowValueWrapperInternalKt.debuggerCapture(FlowValueWrapperInternal.kt:44)
	at kotlinx.coroutines.selects.SelectImplementation.complete(Select.kt:695)
	at kotlinx.coroutines.selects.SelectImplementation.doSelectSuspend(Select.kt:443)
	at kotlinx.coroutines.selects.SelectImplementation.access$doSelectSuspend(Select.kt:241)
	at kotlinx.coroutines.selects.SelectImplementation$doSelectSuspend$1.invokeSuspend(Select.kt)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:608)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:873)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:763)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:750)
@arkandias arkandias changed the title GraphQL plugin fails to evaluation graphql.config.ts GraphQL plugin fails to load TS config file graphql.config.ts Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant