houdini-react 2.0.0-go.15 → 2.0.0-go.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini-react",
3
- "version": "2.0.0-go.15",
3
+ "version": "2.0.0-go.17",
4
4
  "description": "The React plugin for houdini",
5
5
  "keywords": [
6
6
  "typescript",
@@ -33,7 +33,6 @@
33
33
  "cookies": "^0.8.0",
34
34
  "estraverse": "^5.3.0",
35
35
  "express": "^4.18.2",
36
- "graphql": "^15.8.0",
37
36
  "graphql-yoga": "^4.0.4",
38
37
  "react": "^19.0.0",
39
38
  "react-dom": "^19.0.0",
@@ -42,6 +41,9 @@
42
41
  "rollup": "^4.28.1",
43
42
  "use-deep-compare-effect": "^1.8.1"
44
43
  },
44
+ "peerDependencies": {
45
+ "graphql": ">=16"
46
+ },
45
47
  "files": [
46
48
  "bin",
47
49
  "postInstall.js",
@@ -79,12 +81,12 @@
79
81
  }
80
82
  },
81
83
  "optionalDependencies": {
82
- "houdini-react-darwin-x64": "2.0.0-go.15",
83
- "houdini-react-darwin-arm64": "2.0.0-go.15",
84
- "houdini-react-linux-x64": "2.0.0-go.15",
85
- "houdini-react-linux-arm64": "2.0.0-go.15",
86
- "houdini-react-win32-x64": "2.0.0-go.15",
87
- "houdini-react-win32-arm64": "2.0.0-go.15"
84
+ "houdini-react-darwin-x64": "2.0.0-go.17",
85
+ "houdini-react-darwin-arm64": "2.0.0-go.17",
86
+ "houdini-react-linux-x64": "2.0.0-go.17",
87
+ "houdini-react-linux-arm64": "2.0.0-go.17",
88
+ "houdini-react-win32-x64": "2.0.0-go.17",
89
+ "houdini-react-win32-arm64": "2.0.0-go.17"
88
90
  },
89
91
  "bin": "bin/houdini-react",
90
92
  "scripts": {
package/postInstall.js CHANGED
@@ -5,7 +5,7 @@ const https = require('https')
5
5
  const child_process = require('child_process')
6
6
 
7
7
  // Adjust the version you want to install. You can also make this dynamic.
8
- const BINARY_DISTRIBUTION_VERSION = '2.0.0-go.15'
8
+ const BINARY_DISTRIBUTION_VERSION = '2.0.0-go.17'
9
9
 
10
10
  // Windows binaries end with .exe so we need to special case them.
11
11
  const binaryName = process.platform === 'win32' ? 'houdini-react.exe' : 'houdini-react'
@@ -14,7 +14,8 @@ export type MutationHandler<_Result, _Input, _Optimistic extends GraphQLObject>
14
14
  metadata?: App.Metadata
15
15
  fetch?: typeof globalThis.fetch
16
16
  optimisticResponse?: _Optimistic
17
- }) => Promise<QueryResult<_Result, _Input>>
17
+ abortController?: AbortController
18
+ }) => Promise<void>
18
19
 
19
20
  export function useMutation<
20
21
  _Result extends GraphQLObject,
@@ -35,20 +36,35 @@ export function useMutation<
35
36
  const [session] = useSession()
36
37
 
37
38
  // sending the mutation just means invoking the observer's send method
38
- const mutate: MutationHandler<_Result, _Input, _Optimistic> = ({
39
+ const mutate: MutationHandler<_Result, _Input, _Optimistic> = async ({
39
40
  metadata,
40
41
  fetch,
41
42
  variables,
43
+ abortController,
42
44
  ...mutationConfig
43
- }) =>
44
- observer.send({
45
+ }) => {
46
+ const result = await observer.send({
45
47
  variables,
46
48
  metadata,
47
49
  session,
50
+ abortController,
48
51
  stuff: {
49
52
  ...mutationConfig,
50
53
  },
51
54
  })
52
55
 
56
+ if (result.errors && result.errors.length > 0) {
57
+ const err = new RuntimeGraphQLError(
58
+ result.errors.map((error) => error.message).join('. ')
59
+ )
60
+ err.raw = result.errors
61
+ throw err
62
+ }
63
+ }
64
+
53
65
  return [pending, mutate]
54
66
  }
67
+
68
+ export class RuntimeGraphQLError extends Error {
69
+ raw: QueryResult['errors'] = []
70
+ }