Skip to content

Commit

Permalink
Merge pull request #6182 from ailohq/usemutation-optional-payload-arg…
Browse files Browse the repository at this point in the history
…ument

[TypeScript] Fix useMutation requires payload argument
  • Loading branch information
fzaninotto authored Apr 26, 2021
2 parents d21b578 + 5d0cf4e commit b479c05
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/ra-core/src/dataProvider/useMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ const useMutation = (
export interface Mutation {
type: string;
resource?: string;
payload: object;
payload?: object;
}

export interface MutationOptions {
Expand Down Expand Up @@ -281,7 +281,12 @@ const mergeDefinitionAndCallTimeParameters = (
callTimeQuery?: Mutation | Event,
options?: MutationOptions,
callTimeOptions?: MutationOptions
) => {
): {
type: string;
resource: string;
payload?: object;
options: MutationOptions;
} => {
if (!query && (!callTimeQuery || callTimeQuery instanceof Event)) {
throw new Error('Missing query either at definition or at call time');
}
Expand Down

0 comments on commit b479c05

Please sign in to comment.