-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Simplify useCustomMutation implementation #2034
Conversation
return async (): Promise<any> => { | ||
const clientConfig = options.clientConfig || {} | ||
const createMutationFnWithAuth = (): MutationFunction<TData, TMutationVariables> => { | ||
return async (args): Promise<TData> => { |
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.
The core change is in this line. We update the mutation function to take arguments.
@@ -105,7 +105,7 @@ const NOCK_DELAY = 50 | |||
/** Mocks DELETE, PATCH, POST, and PUT so we don't have to look up which verb an endpoint uses. */ | |||
export const mockMutationEndpoints = ( | |||
matchingPath: string, | |||
response: string | object | undefined, | |||
response: string | object | undefined | ((uri: string, requestBody: any) => object), |
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.
this is to support the test case where i need to verify the http header is sent.
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.
LGTM
This is a follow up for the previous PR #2030
This PR simplifies the implementation structure to remove the if/else block that contains some duplicated code:
Before
After