Skip to content
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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