Make mocking configuration less confusing.#1835
Conversation
Setting mocks to false will always disable mocking.
|
@deftomat: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/ |
| } | ||
|
|
||
| if (mocks || typeof mockEntireSchema !== 'undefined') { | ||
| if (mocks || (typeof mockEntireSchema !== 'undefined' && mocks !== false)) { |
There was a problem hiding this comment.
Hey @deftomat Thanks for looking into this! I've been meaning to look at it. Question: wouldn't this end up doing the same thing?
| if (mocks || (typeof mockEntireSchema !== 'undefined' && mocks !== false)) { | |
| if (mocks) { |
There was a problem hiding this comment.
To my understanding, this is the current intended behavior:
mocks: false
- no matter what, no mocks get added
mocks: true
- by default, mocks all resolvers
mockEntireSchema: falseto overwrite this
There was a problem hiding this comment.
Well, in my code, you can enable mocks by setting mockEntireSchema without bothering about mocks property.
By looking at the next lines, you can see that it is an intended behaviour to be able to enable mocks just by using mockEntireSchema.
There was a problem hiding this comment.
Yep! That makes more sense actually 👌 Thanks for clarifying @deftomat
|
@deftomat Can you add this line to |
|
@JakeDawkins done! |
|
Thanks for the help @deftomat! |
We had a few WTF? situations 😉 with the following Apollo server config:
Everyone in our team assumed that you can disable the mocks by setting the
mocksproperty to false.However, according to:
apollo-server/packages/apollo-server-core/src/ApolloServer.ts
Line 257 in a12673a
The mocks will be enabled when you provide
mocksEntireSchematogether withmocks. It doesn't matter ifmocksistrueorfalseor an object.I'm not sure if this is an intended behaviour but I can definitely say that it is really confusing.
Can we update it to disable mocks when
mocksproperty isfalse?(Feel free to close this PR if the current behaviour is an intended behaviour)