@graphcommerce/react-hook-form 3.3.3 → 3.3.4

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,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 3.3.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1660](https://github.com/graphcommerce-org/graphcommerce/pull/1660) [`75ae24a93`](https://github.com/graphcommerce-org/graphcommerce/commit/75ae24a93bd74e3b9b7efda21ec7ba6fbe9a3a75) Thanks [@paales](https://github.com/paales)! - Remove heuristicEncode for GraphQL input objects provided by react-hook-form
8
+
3
9
  ## 3.3.3
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.3",
5
+ "version": "3.3.4",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -26,6 +26,7 @@ export function assertFormGqlOperation<V, Q = Record<string, unknown>>(
26
26
  }
27
27
  }
28
28
 
29
+ /** Bindings between react-hook-form's useForm and Apollo Client's useMutation hook. */
29
30
  export function useFormGqlMutation<Q, V>(
30
31
  document: TypedDocumentNode<Q, V>,
31
32
  options: UseFormGraphQlOptions<Q, V> = {},
@@ -116,20 +116,8 @@ export function handlerFactory<Q, V>(document: TypedDocumentNode<Q, V>): UseGqlD
116
116
  const required = requiredPartial as Required
117
117
  const encoding = encodingPartial as Encoding
118
118
 
119
- function heuristicEncode(val: string) {
120
- if (Number(val).toString() === val) return Number(val)
121
- if (val === 'true') return true
122
- if (val === 'false') return false
123
- return val
124
- }
125
-
126
119
  function encodeItem(enc: FieldTypes, val: unknown) {
127
120
  if (Array.isArray(val)) return val.map((v, i) => encodeItem(enc[i], v))
128
- if (val && typeof val === 'object') {
129
- return Object.fromEntries(
130
- Object.entries(val).map(([key, v]) => [key, heuristicEncode(v as string)]),
131
- )
132
- }
133
121
  if (enc === 'Boolean') return Boolean(val)
134
122
  if (enc === 'Float' || enc === 'Int') return Number(val)
135
123
  return val