Graphql-compose and graphql-compose-mongoose doesn't work with NextJs api routes
Graphql-compose and graphql-compose-mongoose doesn't work with NextJs api routes (serverless):
-
ComposeWithMongoose or ComposeMongoose Error: You try to generate GraphQL Type with name from mongoose model but this type already exists in SchemaComposer. Please choose another type name "composeWithMongoose(model, { name: 'NewTypeName' })", or reuse existed type "schemaComposer.getOTC('TypeName')", or remove type from SchemaComposer before calling composeWithMongoose method "schemaComposer.delete('TypeName')".
-
schemaComposer.buildSchema() Error: Schema must contain uniquely named types but contains multiple types named "ErrorInterface"
Without much info to go on here - its going to be hard for anyone to solve your problem for you.
But have you tried checking the schemaComposer size before trying to compose additional types.
if (schemaComposer.size === 0) {
composeMongoose(...)
}