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
Regression in 10.0.19: Error: Cannot determine a GraphQL input type ("....") for the "...". Make sure your class is decorated with an appropriate decorator. at InputTypeFactory.create #2360
Comments
If I revert to 10.0.18 the error disappears, it appears in 10.0.19. |
I have the same issue just for reference: @ResolveField(() => Organization)
async organization(@Parent() { organizationId }: Invitation): Promise<Partial<Organization> | Error> {
return this.organizationService.load(organizationId)
} @ObjectType()
@Directive('@key(fields: "_id")')
export class Organization {
@Field(() => ObjectId)
_id: ObjectId
@Field(() => Date)
createdAt: Date
@Field(() => Date)
updatedAt: Date
} Error: CannotDetermineInputTypeError: Cannot determine a GraphQL input type ("Organization") for the "organization". Make sure your class is decorated with an appropriate decorator.
at InputTypeFactory.create (/Users/joaoribeiro/Projects/seeds/seed-backend/node_modules/@nestjs/graphql/dist/schema-builder/factories/input-type.factory.js:19:23)
at /Users/joaoribeiro/Projects/seeds/seed-backend/node_modules/@nestjs/graphql/dist/schema-builder/factories/input-type-definition.factory.js:48:52
at Array.forEach (<anonymous>)
at /Users/joaoribeiro/Projects/seeds/seed-backend/node_modules/@nestjs/graphql/dist/schema-builder/factories/input-type-definition.factory.js:46:33 This still works properly for cases where I implement ObjectType and InputType simultaneous: @ObjectType()
@InputType('MinimalUserInput')
export class MinimalUser extends PickType(User, [
'_id',
'name',
'familyName',
'givenName',
'middleName',
'nickname',
'picture',
] as const) {
@Field({ nullable: true })
picture?: string
} But I cannot do this with most of the cases because even apart from business logic constrains it then hit what it seams another bug where you cannot implement InputType and directives like "Key" or "shareable" with "InputType". |
This looks like a regression caused by this PR cc @roypeled #2212 Could any of you @andreialecu @JonnyBGod provide a minimum reproduction repository to help us fix this issue asap? |
I am a bit busy but will try to get it for you later today. There is another issue that maybe you can chack at the same time. Or if you prefer let me know and I will create a separate issue. The problem shows when using ObjectType and InutType simultaneously and also applying directives such as Key and Shareable. It throws errors syaing that you cannot use these directives with InputType. |
FWIW I worked around this by declaring the field on the entity. class Entity {
@Field(...)
foo?: never;
}
@Resolver(Entity)
class Resolver {
@ResolveField()
foo() { ... }
} |
Sorry did not manage to replicate with a simple repo yet. It looks odd, trying to replicate two of my entities simplified and it is working well on a simple repo. Also tried with abstract class extentions and still works. Also removed most of my package versioning conflicts on my project (thought it could be a graphql version conflivting). still did not solve this. Will keep investigating... |
@kamilmysliwiec repro at: https://github.com/andreialecu/nest-repro-2360
|
As a side note: It would be great if the error message above pointed to something more specific for other cases where it is more legitimate. In our actual project, we have similarly named fields across multiple resolvers. It was impossible to pinpoint which one it was throwing on without directly troubleshooting the NestJS source code. |
I've run into the same issue, but I don't see much activity here - @andreialecu have you by any chance discovered a workaround? |
Hey everyone, sorry for the late reply, I realize it was my refactor of metadata storage that caused this issue. Here is the fix: @kamilmysliwiec I would appreciate a merge, and if you can find the time to create a test for this case it would be amazing, I tried but for some reason I couldn't get the test to work with field resolver. I did test the repro: https://github.com/andreialecu/nest-repro-2360 and the fix worked for that. |
Is there an existing issue for this?
Current behavior
After upgrading to 10.0.22 I started getting a weird error about in a pretty big project:
There was no context as to where this error originated, so I had to add various
console.log
s inside@nestjs/graphql
to find it.I eventually tracked it down to this piece of code:
The error was about an InputType being expected on a
@ResolveField()
so this is very bizarre.Here's the relevant code:
Minimum reproduction code
nope
Steps to reproduce
No response
Expected behavior
A
@ResolveField()
should not participate in inputs, I suspect a refactoring broke this.Package version
10.0.19
Graphql version
No response
NestJS version
No response
Node.js version
No response
In which operating systems have you tested?
Other
No response
The text was updated successfully, but these errors were encountered: