This repository has been archived by the owner on Apr 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 786
Added custom cache option to MockedProvider #2142
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jbaxleyiii
approved these changes
Jun 27, 2018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question, but dope!
@@ -18,7 +18,7 @@ export class MockedProvider extends React.Component<any, any> { | |||
const link = new MockLink(this.props.mocks, this.props.addTypename); | |||
this.client = new ApolloClient({ | |||
link, | |||
cache: new Cache({ addTypename: this.props.addTypename }), | |||
cache: this.props.cache || new Cache({ addTypename: this.props.addTypename }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JakeDawkins should we warn if you have a mismatch from addTypename
as a prop vs in the cache?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about that, but how do you think we could do that if they can pass in arbitrary caches?
rosskevin
approved these changes
Jul 3, 2018
5 tasks
Ooops - @JakeDawkins it looks like we've already merged this functionality in via #2142. Thanks for working on this! 🙇 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Someone using MockedProvider in a project with fragments ran into an issue where they couldn't test a component, because of the default
HeuristicFragmentMatcher
. Since there was no way to control what cache was used with the originalMockedProvider
, I added a prop to it that allows a customCache
to be passed in.This also will allow people to preload caches, etc when testing components
I added an example in the tests
Checklist: