Skip to content

Commit 70047b7

Browse files
committed
fix: do not use cache for generating a new TypeComposer if provided new type name
1 parent dfeb5a8 commit 70047b7

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22
"eslint.validate": ["javascript"],
33
"javascript.validate.enable": false,
44
"javascript.autoClosingTags": false,
5-
"eslint.autoFixOnSave": true
5+
"eslint.autoFixOnSave": true,
6+
"editor.codeActionsOnSave": {
7+
"source.fixAll.eslint": true
8+
}
69
}

src/fieldsConverter.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,12 @@ export function convertModelToGraphQL<TSource, TContext>(
130130
}
131131

132132
// if model already has generated ObjectTypeComposer early, then return it
133-
if (sc.has(model.schema)) {
133+
if (sc.has(model.schema) && sc.has(typeName)) {
134+
if (sc.get(model.schema) !== sc.get(typeName)) {
135+
throw new Error(
136+
`You try to generate GrpahQL Type with name ${typeName} from mongoose model but this type already exists in SchemaComposer. Please choose another type name or remove existed type from schemaComposer.`
137+
);
138+
}
134139
return sc.getOTC(model.schema);
135140
}
136141

0 commit comments

Comments
 (0)