e2e tests: Undefined type error. Provide explicit type for the "user" of the "AuthResolver" class.
See original GitHub issueBug
Steps to reproduce
- fresh install the repository and follow the guide on readme (https://github.com/fivethree-team/nestjs-prisma-starter#prisma-setup)
- run e2e tests
Expected behaviour
e2e tests passed
Actual behaviour
$ jest --config ./test/jest-e2e.json
FAIL test/app.resolver.e2e-spec.ts
● AppResolver (e2e) › helloWorld (Query)
Undefined type error. Make sure you are providing an explicit type for the "user" of the "AuthResolver" class.
at TypeMetadataStorageHost.compileExternalFieldResolverMetadata (../node_modules/@nestjs/graphql/dist/schema-builder/storages/type-metadata.storage.js:256:23)
at ../node_modules/@nestjs/graphql/dist/schema-builder/storages/type-metadata.storage.js:240:22
at Array.forEach (<anonymous>)
at TypeMetadataStorageHost.compileFieldResolverMetadata (../node_modules/@nestjs/graphql/dist/schema-builder/storages/type-metadata.storage.js:229:18)
at TypeMetadataStorageHost.compile (../node_modules/@nestjs/graphql/dist/schema-builder/storages/type-metadata.storage.js:144:14)
at GraphQLSchemaFactory.<anonymous> (../node_modules/@nestjs/graphql/dist/schema-builder/graphql-schema.factory.js:38:57)
at ../node_modules/@nestjs/graphql/node_modules/tslib/tslib.js:114:75
at Object.__awaiter (../node_modules/@nestjs/graphql/node_modules/tslib/tslib.js:110:16)
● AppController (e2e) › /hello/:name (GET)
Undefined type error. Make sure you are providing an explicit type for the "user" of the "AuthResolver" class.
[...]
How can I fix this? Thank you!
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Error: Undefined type error. Make sure you are providing an ...
Error : Undefined type error. Make sure you are providing an explicit type for the "user" of the "Transaction" class.
Read more >type-graphql/Lobby - Gitter
Error : Unable to infer GraphQL type from TypeScript reflection system. You need to provide explicit type for 'hasStaging' of 'DeploysCategory' class.
Read more >Nest.js GraphQL Integration Testing Tutorial - YouTube
In this video, we learn how to write integration tests against a GraphQL server in Nest.js.
Read more >Release 9.19.7 Internet Systems Consortium
or an error is received, at which point the user's original recursive ... The format of the data is type- and sometimes class-specific....
Read more >An E2E test scenario in NestJS for a GraphQL mutation - Selleo
A function to set up the app for the E2E's test suite: ... DocumentStatus } from 'src/document/entities/document.type' import { GoogleStorageService } from ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
After diving a bit into the problem and reading this illuminating issue https://github.com/nestjs/graphql/issues/226, I found that my problem is due to this portion of code
https://github.com/fivethree-team/nestjs-prisma-starter/blob/d628befcf507f4c7ab7b0fb55697ef997063e40e/src/resolvers/auth/auth.resolver.ts#L46-L49
and in particular to
https://github.com/fivethree-team/nestjs-prisma-starter/blob/d628befcf507f4c7ab7b0fb55697ef997063e40e/src/resolvers/auth/auth.resolver.ts#L46
where, as the error message says, I’m not providing an explicit type for “user”.
Fix
Import the user model and add the type explicitly to the decorator for the user method.
@marcjulian Sure, just did it. I hope it might help.