I'm trying to build a monorepo of nestjs + svelte applications using nx, generated all applications and libraries using the CLI/nx commands.
Initially I thought this error is because the model is imported from a shared library but then I moved the definitions to the output of that graphql query right into the root resolver.
Just pnpm install
and pnpm start
then go to localhost:3100/graphql
and run:
query {
getHealth{
status
}
}
it throws:
{
"errors": [
{
"message": "status is not defined",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"getHealth"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"stacktrace": [
"ReferenceError: status is not defined",
" at RootResolver.getHealth (D:\\00 SOFTWARE\\temp\\nx-playground\\dist\\apps\\graphql-server\\webpack:\\nx-playground\\apps\\graphql-server\\src\\app\\resolvers\\root.resolver.ts:23:40)",
" at D:\\00 SOFTWARE\\temp\\nx-playground\\node_modules\\.pnpm\\@nestjs+core@9.0.8_j3qpqvsfitzwbryyelxorkuzfa\\node_modules\\@nestjs\\core\\helpers\\external-context-creator.js:70:33",
" at processTicksAndRejections (node:internal/process/task_queues:96:5)"
]
}
}
}
],
"data": null
}
Any ideas on why this is or how to get it working?
Played with your reproduction, in your @Query()
you have this.tracer.info(log, 'getHealth', status)
, but you don't define status
anywhere. Seems that Typescript isn't complaining because lib.dom.d.ts
has a global status
value. You should make sure that your Nest projects are using @types/node
instead of the lib.dom.d.ts
as it's a Node project.
Removing the this.tracer
line caused a successful response from the server, so it's just a non-defined variable being referenced