Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make mocking configuration less confusing. #1835

Merged
merged 5 commits into from
Oct 30, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/apollo-server-core/src/ApolloServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ export class ApolloServerBase {
});
}

if (mocks || typeof mockEntireSchema !== 'undefined') {
if (mocks || (typeof mockEntireSchema !== 'undefined' && mocks !== false)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Suggested change
if (mocks || (typeof mockEntireSchema !== 'undefined' && mocks !== false)) {
if (mocks) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: false to overwrite this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! That makes more sense actually 👌 Thanks for clarifying @deftomat

addMockFunctionsToSchema({
schema: this.schema,
mocks:
Expand Down