Skip to content

Commit 8e629fa

Browse files
authored
chore: provide a better error message when users attempt to call composeWithMongooseDiscriminators without first registering discriminators on their base model
Provide a better error message when users attempt to call `composeWithMongooseDiscriminators` without first registering discriminators on their base model (eg `baseModel.discriminator("ChildModel", ChildModelSchema)`
1 parent 7f57391 commit 8e629fa

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/discriminators/DiscriminatorTypeComposer.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ export class DiscriminatorTypeComposer<TSource, TContext> extends ObjectTypeComp
8585
opts?: ComposeWithMongooseDiscriminatorsOpts<any>
8686
): DiscriminatorTypeComposer<TSrc, TCtx> {
8787
if (!baseModel || !baseModel.discriminators) {
88-
throw Error('Discriminator Key not Set, Use composeWithMongoose for Normal Collections');
88+
throw Error(
89+
'Discriminator Key not Set, have you already registered discriminators on your base model? ' +
90+
'Otherwise, use composeWithMongoose for Normal Collections'
91+
);
8992
}
9093

9194
if (!(schemaComposer instanceof SchemaComposer)) {

0 commit comments

Comments
 (0)