mercurius-js / mercurius

Implement GraphQL servers and gateways with Fastify
https://mercurius.dev/
MIT License
2.33k stars 234 forks source link

Better error messages on passing array of executable schemas. #984

Closed brainrepo closed 1 year ago

brainrepo commented 1 year ago

In Mercurius' schema option, we can pass schemas as either a string or an executable schema.

If we pass them as a string, we can also pass an array of schemas in the string type, in which case Mercurius will merge them.

However, if we pass them as an executable schema, we can only pass one. Currently, there is no check to prevent the passing of an array of executable schemas. If we pass two executable schemas, we get an error.

Possible solutions:

https://github.com/mercurius-js/mercurius/blob/b6ac05724b7715ba90d8686aa8218fc8de10ffd1/index.js#L148-L171

simoneb commented 1 year ago

Why would you need to pass an array of executable schemas?

brainrepo commented 1 year ago

Why would you need to pass an array of executable schemas?

It can be useful if you decide to split in modules your GraphQL application. In my previous project (pretty big) we divided the GraphQL api in domains/modules and each module was responsible of just few types and resolvers.

simoneb commented 1 year ago

understood, makes sense