Description
Describe the bug
When I test my project with mocha
, it runs fine. When I run with mocha --watch
, the first test passes and the second one reports Error: Schema must contain uniquely named types but contains multiple types named "CreateNoteResponse".
To Reproduce
Using this .mocharrc.js
:
'use strict';
module.exports = {
extension: ['ts'],
opts: false,
require: [
'reflect-metadata',
'ts-node/register'
],
recursive: true,
spec: 'src/**/*.test.ts',
'watch-files': ['src/**/*.ts', 'test/*.ts'],
};
- Run
mocha --watch
- Observe tests pass.
- Save a watched file.
- Observe an error.
Expected behavior
I'd expect that reloading works. Possibly related to Webpack hot reload issues in #289 ?
Logs
Error: Schema must contain uniquely named types but contains multiple types named "CreateNoteResponse".
at typeMapReducer (node_modules/graphql/type/schema.js:262:13)
at Array.reduce (<anonymous>)
at new GraphQLSchema (node_modules/graphql/type/schema.js:145:28)
at Function.generateFromMetadataSync (node_modules/type-graphql/dist/schema/schema-generator.js:31:24)
at Function.<anonymous> (node_modules/type-graphql/dist/schema/schema-generator.js:16:33)
Enviorment (please complete the following information):
- OS: macOS 10.14.6
- Node: v10.16.3
- Package version: v0.17.6
- TypeScript version: 3.8.2
Additional context
Way back when I set up the project, I used Jest instead. I don't believe it had this issue, but I can't confirm that.
Also, I attempted to solve this with getMetadataStorage().clear()
before running buildSchema
, but that resulted in Error: Type Query must define one or more fields.
.
The issue occurs regardless of whether or not you use buildSchema
or buildSchemaSync
.