@graphcommerce/react-hook-form 3.3.4 → 3.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/useFormGql.tsx +3 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 3.3.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1665](https://github.com/graphcommerce-org/graphcommerce/pull/1665) [`1f2e14ba8`](https://github.com/graphcommerce-org/graphcommerce/commit/1f2e14ba8b674b87257a123e8cb215157890eb22) Thanks [@paales](https://github.com/paales)! - Make sure the onComplete callback also sends the variables
|
|
8
|
+
|
|
3
9
|
## 3.3.4
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/react-hook-form",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "3.3.
|
|
5
|
+
"version": "3.3.5",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
package/src/useFormGql.tsx
CHANGED
|
@@ -12,10 +12,7 @@ import { UseFormProps, UseFormReturn, UnpackNestedValue, DeepPartial } from 'rea
|
|
|
12
12
|
import diff from './diff'
|
|
13
13
|
import { useGqlDocumentHandler, UseGqlDocumentHandler } from './useGqlDocumentHandler'
|
|
14
14
|
|
|
15
|
-
export type OnCompleteFn<Q> = (
|
|
16
|
-
data: FetchResult<Q>,
|
|
17
|
-
client: ApolloClient<unknown>,
|
|
18
|
-
) => void | Promise<void>
|
|
15
|
+
export type OnCompleteFn<Q, V> = (data: FetchResult<Q>, variables: V) => void | Promise<void>
|
|
19
16
|
|
|
20
17
|
type UseFormGraphQLCallbacks<Q, V> = {
|
|
21
18
|
/**
|
|
@@ -23,7 +20,7 @@ type UseFormGraphQLCallbacks<Q, V> = {
|
|
|
23
20
|
* Mutation. Also allows you to send false to skip submission.
|
|
24
21
|
*/
|
|
25
22
|
onBeforeSubmit?: (variables: V) => V | false | Promise<V | false>
|
|
26
|
-
onComplete?: OnCompleteFn<Q>
|
|
23
|
+
onComplete?: OnCompleteFn<Q, V>
|
|
27
24
|
}
|
|
28
25
|
|
|
29
26
|
export type UseFormGraphQlOptions<Q, V> = UseFormProps<V> & UseFormGraphQLCallbacks<Q, V>
|
|
@@ -81,7 +78,7 @@ export function useFormGql<Q, V>(
|
|
|
81
78
|
// if (variables === false) onInvalid?.(formValues, event)
|
|
82
79
|
|
|
83
80
|
const result = await execute({ variables })
|
|
84
|
-
if (onComplete && result.data) await onComplete(result,
|
|
81
|
+
if (onComplete && result.data) await onComplete(result, variables)
|
|
85
82
|
|
|
86
83
|
// Reset the state of the form if it is unmodified afterwards
|
|
87
84
|
if (typeof diff(form.getValues(), formValues) === 'undefined')
|