@graphcommerce/react-hook-form 9.0.4-canary.1 → 9.0.4-canary.11
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,33 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 9.0.4-canary.11
|
|
4
|
+
|
|
5
|
+
## 9.0.4-canary.10
|
|
6
|
+
|
|
7
|
+
### Patch Changes
|
|
8
|
+
|
|
9
|
+
- [#2487](https://github.com/graphcommerce-org/graphcommerce/pull/2487) [`935f8f9`](https://github.com/graphcommerce-org/graphcommerce/commit/935f8f9ebe5e79b336e56d40cb1ec96ce17b84d7) - Remove dependency on Magento for @graphcommerec/react-hook-form ([@paales](https://github.com/paales))
|
|
10
|
+
|
|
11
|
+
## 9.0.4-canary.9
|
|
12
|
+
|
|
13
|
+
## 9.0.4-canary.8
|
|
14
|
+
|
|
15
|
+
## 9.0.4-canary.7
|
|
16
|
+
|
|
17
|
+
## 9.0.4-canary.6
|
|
18
|
+
|
|
19
|
+
## 9.0.4-canary.5
|
|
20
|
+
|
|
21
|
+
## 9.0.4-canary.4
|
|
22
|
+
|
|
23
|
+
## 9.0.4-canary.3
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- [#2477](https://github.com/graphcommerce-org/graphcommerce/pull/2477) [`8015eab`](https://github.com/graphcommerce-org/graphcommerce/commit/8015eabc130dacf1f2703980cd5f0ad2c550aa4d) - Upgraded to @apollo/client 3.12.3 without impacting typescript compilation performance. ([@paales](https://github.com/paales))
|
|
28
|
+
|
|
29
|
+
## 9.0.4-canary.2
|
|
30
|
+
|
|
3
31
|
## 9.0.4-canary.1
|
|
4
32
|
|
|
5
33
|
## 9.0.4-canary.0
|
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": "9.0.4-canary.
|
|
5
|
+
"version": "9.0.4-canary.11",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
15
|
"@apollo/client": "*",
|
|
16
|
-
"@graphcommerce/eslint-config-pwa": "^9.0.4-canary.
|
|
17
|
-
"@graphcommerce/prettier-config-pwa": "^9.0.4-canary.
|
|
18
|
-
"@graphcommerce/typescript-config-pwa": "^9.0.4-canary.
|
|
16
|
+
"@graphcommerce/eslint-config-pwa": "^9.0.4-canary.11",
|
|
17
|
+
"@graphcommerce/prettier-config-pwa": "^9.0.4-canary.11",
|
|
18
|
+
"@graphcommerce/typescript-config-pwa": "^9.0.4-canary.11",
|
|
19
19
|
"@mui/utils": "^5",
|
|
20
20
|
"graphql": "^16.6.0",
|
|
21
21
|
"react": "^18.2.0",
|
package/src/useFormGql.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import type {
|
|
|
2
2
|
FetchResult,
|
|
3
3
|
LazyQueryHookOptions,
|
|
4
4
|
LazyQueryResultTuple,
|
|
5
|
+
MaybeMasked,
|
|
5
6
|
MutationHookOptions,
|
|
6
7
|
MutationTuple,
|
|
7
8
|
TypedDocumentNode,
|
|
@@ -16,7 +17,10 @@ import type { UseGqlDocumentHandler } from './useGqlDocumentHandler'
|
|
|
16
17
|
import { useGqlDocumentHandler } from './useGqlDocumentHandler'
|
|
17
18
|
import { tryAsync } from './utils/tryTuple'
|
|
18
19
|
|
|
19
|
-
export type OnCompleteFn<Q, V> = (
|
|
20
|
+
export type OnCompleteFn<Q, V> = (
|
|
21
|
+
data: FetchResult<MaybeMasked<Q>>,
|
|
22
|
+
variables: V,
|
|
23
|
+
) => void | Promise<void>
|
|
20
24
|
|
|
21
25
|
type UseFormGraphQLCallbacks<Q, V> = {
|
|
22
26
|
/**
|
|
@@ -84,7 +88,7 @@ export type UseFormGqlMethods<Q, V extends FieldValues> = Omit<
|
|
|
84
88
|
'encode' | 'type'
|
|
85
89
|
> &
|
|
86
90
|
Pick<UseFormReturn<V>, 'handleSubmit'> & {
|
|
87
|
-
data?: Q | null
|
|
91
|
+
data?: MaybeMasked<Q> | null
|
|
88
92
|
error?: ApolloError
|
|
89
93
|
submittedVariables?: V
|
|
90
94
|
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
mutation TestShippingAddressForm(
|
|
2
|
-
$cartId: String!
|
|
3
|
-
$address: CartAddressInput!
|
|
4
|
-
$customerNote: String = "joi"
|
|
5
|
-
) {
|
|
6
|
-
setShippingAddressesOnCart(
|
|
7
|
-
input: {
|
|
8
|
-
cart_id: $cartId
|
|
9
|
-
shipping_addresses: [{ address: $address, customer_notes: $customerNote }]
|
|
10
|
-
}
|
|
11
|
-
) {
|
|
12
|
-
cart {
|
|
13
|
-
id
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
2
|
-
import { ApolloClient, InMemoryCache } from '@apollo/client'
|
|
3
|
-
import { renderHook } from '@testing-library/react'
|
|
4
|
-
import { TestShippingAddressFormDocument } from '../__mocks__/TestShippingAddressForm.gql'
|
|
5
|
-
import { useFormGqlMutation } from '../src/useFormGqlMutation'
|
|
6
|
-
|
|
7
|
-
describe('useFormGqlMutation', () => {
|
|
8
|
-
const { result } = renderHook(() =>
|
|
9
|
-
useFormGqlMutation(
|
|
10
|
-
TestShippingAddressFormDocument,
|
|
11
|
-
{},
|
|
12
|
-
{
|
|
13
|
-
client: new ApolloClient({
|
|
14
|
-
cache: new InMemoryCache(),
|
|
15
|
-
}),
|
|
16
|
-
},
|
|
17
|
-
),
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
it('can register stuff', () => {
|
|
21
|
-
result.current.register('address.telephone')
|
|
22
|
-
result.current.register('customerNote')
|
|
23
|
-
result.current.register('address.street.0')
|
|
24
|
-
|
|
25
|
-
// @ts-expect-error should not be posssible
|
|
26
|
-
result.current.register('address.street.hoi')
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it('extracts required fields correctly', () => {
|
|
30
|
-
expect(result.current.required).toEqual({ address: true, cartId: true, customerNote: false })
|
|
31
|
-
})
|
|
32
|
-
it('extracts defaults correctly', () => {
|
|
33
|
-
expect(result.current.defaultVariables).toEqual({ customerNote: 'joi' })
|
|
34
|
-
})
|
|
35
|
-
})
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { TestShippingAddressFormDocument } from '../__mocks__/TestShippingAddressForm.gql'
|
|
2
|
-
import { handlerFactory } from '../src/useGqlDocumentHandler'
|
|
3
|
-
|
|
4
|
-
describe('useGqlDocumentHandler', () => {
|
|
5
|
-
const {
|
|
6
|
-
required,
|
|
7
|
-
defaultVariables: defaults,
|
|
8
|
-
encode,
|
|
9
|
-
} = handlerFactory(TestShippingAddressFormDocument)
|
|
10
|
-
|
|
11
|
-
const address = {
|
|
12
|
-
cartId: '12',
|
|
13
|
-
customerNote: 'hoi',
|
|
14
|
-
address: {
|
|
15
|
-
firstname: 'Firstname',
|
|
16
|
-
lastname: 'Lastname',
|
|
17
|
-
company: 'GraphComemrce',
|
|
18
|
-
country_code: 'NL',
|
|
19
|
-
street: ['Streetline 1', 'Streetline 2'],
|
|
20
|
-
city: 'City',
|
|
21
|
-
telephone: '0987654321',
|
|
22
|
-
postcode: '1234AB',
|
|
23
|
-
save_in_address_book: true,
|
|
24
|
-
},
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
it('extracts required fields correctly', () => {
|
|
28
|
-
expect(required).toEqual({ address: true, cartId: true, customerNote: false })
|
|
29
|
-
})
|
|
30
|
-
it('extracts defaults correctly', () => {
|
|
31
|
-
expect(defaults).toEqual({ customerNote: 'joi' })
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
it('encodes objects correctly', () => {
|
|
35
|
-
const result = encode(address)
|
|
36
|
-
expect(result).toEqual({
|
|
37
|
-
cartId: '12',
|
|
38
|
-
customerNote: 'hoi',
|
|
39
|
-
address: {
|
|
40
|
-
firstname: 'Firstname',
|
|
41
|
-
lastname: 'Lastname',
|
|
42
|
-
company: 'GraphComemrce',
|
|
43
|
-
country_code: 'NL',
|
|
44
|
-
street: ['Streetline 1', 'Streetline 2'],
|
|
45
|
-
city: 'City',
|
|
46
|
-
telephone: '0987654321',
|
|
47
|
-
postcode: '1234AB',
|
|
48
|
-
save_in_address_book: true,
|
|
49
|
-
},
|
|
50
|
-
})
|
|
51
|
-
})
|
|
52
|
-
})
|