-
-
Notifications
You must be signed in to change notification settings - Fork 454
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
(graphcache) - Change Store constructor to accept options object #622
Conversation
🦋 Changeset is good to goLatest commit: 17d88df We got this. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
That's a good shout 👍
@@ -86,12 +86,10 @@ export const cacheExchange = (opts?: CacheExchangeOpts): Exchange => ({ | |||
forward, | |||
client, | |||
}) => { | |||
if (!opts) opts = {}; |
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.
Good shout on removing this!
Default params also save us some conditional logic:
opts?: CacheExchangeOpts = {}
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.
To be fair, I've just moved it 😆 but typically transpilers will jump through more hoops in the generated code with default params rather than reassigning the argument. It's a minor details though, since we do get the type safety from TypeScript in either cases 👍
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.
default params
are very expensive size wise, see this REPL
4e0f021
to
17d88df
Compare
This changes
cacheExchange
to just pass on its options andStore
to accept an options object as well to make it easier to use directly.storage
is exempted since the rehydration logic is coupled to thecacheExchange
(for now). Bundle size remains unchanged.