@graphcommerce/react-hook-form 3.3.5 → 4.30.0-canary.1
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
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 4.30.0-canary.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`abb15ef4a`](https://github.com/graphcommerce-org/graphcommerce/commit/abb15ef4a79b12eddb32cc006e5d1d31dd06ac2d) Thanks [@paales](https://github.com/paales)! - Added canary releases to GraphCommerce
|
|
8
|
+
|
|
9
|
+
## 4.30.0-canary.0
|
|
10
|
+
|
|
3
11
|
## 3.3.5
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -1,25 +1,35 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
2
|
+
import { ApolloClient, InMemoryCache } from '@apollo/client'
|
|
3
|
+
import { renderHook } from '@testing-library/react'
|
|
2
4
|
import { TestShippingAddressFormDocument } from '../__mocks__/TestShippingAddressForm.gql'
|
|
3
5
|
import { useFormGqlMutation } from '../src/useFormGqlMutation'
|
|
4
6
|
|
|
5
7
|
describe('useFormGqlMutation', () => {
|
|
6
|
-
const {
|
|
7
|
-
|
|
8
|
+
const { result } = renderHook(() =>
|
|
9
|
+
useFormGqlMutation(
|
|
10
|
+
TestShippingAddressFormDocument,
|
|
11
|
+
{},
|
|
12
|
+
{
|
|
13
|
+
client: new ApolloClient({
|
|
14
|
+
cache: new InMemoryCache(),
|
|
15
|
+
}),
|
|
16
|
+
},
|
|
17
|
+
),
|
|
8
18
|
)
|
|
9
19
|
|
|
10
20
|
it('can register stuff', () => {
|
|
11
|
-
register('address.telephone')
|
|
12
|
-
register('customerNote')
|
|
13
|
-
register('address.street.0')
|
|
21
|
+
result.current.register('address.telephone')
|
|
22
|
+
result.current.register('customerNote')
|
|
23
|
+
result.current.register('address.street.0')
|
|
14
24
|
|
|
15
25
|
// @ts-expect-error should not be posssible
|
|
16
|
-
register('address.street.hoi')
|
|
26
|
+
result.current.register('address.street.hoi')
|
|
17
27
|
})
|
|
18
28
|
|
|
19
29
|
it('extracts required fields correctly', () => {
|
|
20
|
-
expect(required).toEqual({ address: true, cartId: true, customerNote: false })
|
|
30
|
+
expect(result.current.required).toEqual({ address: true, cartId: true, customerNote: false })
|
|
21
31
|
})
|
|
22
32
|
it('extracts defaults correctly', () => {
|
|
23
|
-
expect(defaultVariables).toEqual({ customerNote: 'joi' })
|
|
33
|
+
expect(result.current.defaultVariables).toEqual({ customerNote: 'joi' })
|
|
24
34
|
})
|
|
25
35
|
})
|
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": "
|
|
5
|
+
"version": "4.30.0-canary.1",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@graphcommerce/eslint-config-pwa": "^4.1.
|
|
16
|
-
"@graphcommerce/prettier-config-pwa": "^4.0.
|
|
17
|
-
"@graphcommerce/typescript-config-pwa": "^4.0.
|
|
15
|
+
"@graphcommerce/eslint-config-pwa": "^4.1.11-canary.0",
|
|
16
|
+
"@graphcommerce/prettier-config-pwa": "^4.0.7-canary.0",
|
|
17
|
+
"@graphcommerce/typescript-config-pwa": "^4.0.5-canary.0",
|
|
18
18
|
"@playwright/test": "^1.21.1",
|
|
19
19
|
"type-fest": "^2.12.2"
|
|
20
20
|
},
|
package/src/useFormGql.tsx
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FetchResult,
|
|
3
|
-
ApolloClient,
|
|
4
3
|
TypedDocumentNode,
|
|
5
|
-
useApolloClient,
|
|
6
4
|
MutationTuple,
|
|
7
5
|
ApolloError,
|
|
8
6
|
LazyQueryResultTuple,
|
|
@@ -47,7 +45,6 @@ export function useFormGql<Q, V>(
|
|
|
47
45
|
const { onComplete, onBeforeSubmit, document, form, tuple, defaultValues } = options
|
|
48
46
|
const { encode, type, ...gqlDocumentHandler } = useGqlDocumentHandler<Q, V>(document)
|
|
49
47
|
const [execute, { data, error }] = tuple
|
|
50
|
-
const client = useApolloClient()
|
|
51
48
|
|
|
52
49
|
// automatically updates the default values
|
|
53
50
|
const initital = useRef(true)
|