maticzav / graphql-middleware

Split up your GraphQL resolvers in middleware functions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why does `applyMiddleware` mutate the schema passed into it?

lastmjs opened this issue · comments

Hi there,

Thanks for all of the hard work on this library.

I just battled a bug for a while, it was very confusing trying to figure out what was happening. The answer it seems is that applyMiddleware is actually mutating the schema passed into it. I was under the assumption that the API was immutable, considering the modified schema is returned from applyMiddleware. This assumption led me to believe that I could reuse the schema passed in without the middleware applied. This caused big problems.

It would be nice if applyMiddleware could be immutable as the API implies. Is there a reason for it to not be immutable?

If mutations are necessary for some reason, could this be documented somewhere?

Thanks!

This has been resolved now.