graphql-compose-mongoose icon indicating copy to clipboard operation
graphql-compose-mongoose copied to clipboard

Graphql-compose and graphql-compose-mongoose doesn't work with NextJs api routes

Open rockus123 opened this issue 4 years ago • 1 comments

Graphql-compose and graphql-compose-mongoose doesn't work with NextJs api routes (serverless):

  1. 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')".

  2. schemaComposer.buildSchema() Error: Schema must contain uniquely named types but contains multiple types named "ErrorInterface"

rockus123 avatar Mar 15 '21 18:03 rockus123

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(...)

  }

dan-cooke avatar Apr 28 '21 14:04 dan-cooke