-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Pass baseQueryMeta into calculateProvidedBy #1926
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 8a94e05:
|
size-limit report 📦
|
const isQuery = (action: CalculatableAction) => | ||
action.meta.arg.type === 'query' | ||
const isFulfilledQuery = (action: any): action is QueryThunk => | ||
isQuery(action) | ||
const isFulfilledMutation = (action: any): action is MutationThunk => | ||
!isQuery(action) | ||
|
||
return calculateProvidedBy( | ||
endpointDefinitions[action.meta.arg.endpointName][type], | ||
isFulfilled(action) ? action.payload : undefined, | ||
isRejectedWithValue(action) ? action.payload : undefined, | ||
action.meta.arg.originalArgs, | ||
action.meta, | ||
isAnyOf(isRejected, isFulfilledQuery, isFulfilledMutation)(action) | ||
? action.meta.baseQueryMeta | ||
: undefined, |
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 don't know if all of this ceremony is really necessary, but it's probably better than (action.meta as any).baseQueryMeta
or something like that. Very open to ideas here @phryneas if you have one :)
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 think that can be done with less changes - I pushed my suggestion.
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.
Thanks! I need to get a 'ways to narrow types' checklist solidified in my brain.
Hey @msutkowski 👋 I just got around to submitting a PR for a docs update, let me know if it's up to snuff. Would it be easier for your workflow if we merged my branch to yours instead of master? I haven't looked too closely, so I'm not sure what overlap there is. Thanks! |
Patches the work done in #1910 by ensuring that we're exposing
baseQueryMeta
akaRequest
andResponse
objects... which matches thetransformResponse
behavior for consistency. I debated on doing a full use case example here, but it seemed like it wouldn't really provide any real value and would be better served in usage docs.Also note: I didn't update the docs for this as @bever1337 is working on those.