Closed dantman closed 4 years ago
Share your tsconfig.json
that might be the error...
I don't see how the tsconfig can be the error. I checked the source code and don't see any definition for connectionField
. tsconfig can't make a type definition exist when none exist.
{
"compilerOptions": {
"target": "es2016",
"downlevelIteration": true,
"lib": [
"dom",
"dom.iterable",
"es2015.collection",
"es2015.iterable",
"esnext"
],
"declaration": false,
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "CommonJS",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react"
}
}
@dantman I was missing types when I used compilerOptions.types
as some types sis not get loaded. This seemed really similar, so I tried it. Doesn't seems like the case though... I wish you good luck finding a solution.
@dantman did you install the plugin? Guessing you did but not clear.
Adding the connectionPlugin to the schema, of course. But adding a line of code like that does not change the TypeScript types exported by @nexus/schema
.
const schema = makeSchema({
// ... types, etc,
plugins: [
// ... other plugins
connectionPlugin(),
],
});
I'm noticing the same. Also with a custom plugin providing a t.pageField
method.
But adding a line of code like that does not change the TypeScript types exported by @nexus/schema.
It is not about what's exported. It is about the typegen that takes place during reflection. And in that, the plugin does affect the typegen. Anyways, you registered the plugin.
It is not about what's exported. It is about the typegen that takes place during reflection. And in that, the plugin does affect the typegen. Anyways, you registered the plugin.
Oh, the TypeScript types are part of the generated output.
It was not clear in the documentation that the types for the connection plugin's API were part of generated code and they need to be in a place where the tsconfig's includes fill find them.
What did you do to get error away?
Never mind, I'm switching to nexus framework.
There's actually a further issue here. vscode and tsc will pick up on the types.d.ts file. However ts-node users will still encounter this error when they try to run their server.
https://github.com/TypeStrong/ts-node#help-my-types-are-missing
I have the same issue too. Did you removed the errors? How do you generate the types.d.ts file?
@dantman were you able to resolve this when running w/ ts-node? I'm experiencing the same as above
@alchemyjamie you can add --files
option into the command of ts-node or in tsconfig.json like this:
{
"ts-node": {
"files": true
},
"compilerOptions": {
// ....
}
}
original answer I found here https://stackoverflow.com/questions/60782231/ts-node-cant-find-my-type-definition-files
Screenshot
Description
The connectionPlugin says this is how to use the plugin.
However this code gives the error
Property 'connectionField' does not exist on type 'ObjectDefinitionBlock<"User">'.
because there are no type definitions for connectionField. There doesn't even appear to be an extra plugin file to import to add types in.