houdini-react 0.0.0-20240402041921 → 0.0.0-20240402042937

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.
@@ -39,6 +39,7 @@ function useDocumentHandle({
39
39
  }) {
40
40
  const [forwardPending, setForwardPending] = import_react.default.useState(false);
41
41
  const [backwardPending, setBackwardPending] = import_react.default.useState(false);
42
+ const location = (0, import_Router.useLocation)();
42
43
  const [session] = (0, import_Router.useSession)();
43
44
  const client = (0, import_Router.useClient)();
44
45
  const paginationObserver = import_react.default.useMemo(() => {
@@ -56,10 +57,22 @@ function useDocumentHandle({
56
57
  return result;
57
58
  };
58
59
  };
59
- const fetchQuery = (args) => observer.send({
60
- ...args,
61
- session
62
- });
60
+ const fetchQuery = (args) => {
61
+ const usedVariables = Object.fromEntries(
62
+ Object.keys(observer.artifact.input?.fields ?? {}).map((fieldName) => [
63
+ fieldName,
64
+ location.params[fieldName]
65
+ ])
66
+ );
67
+ return observer.send({
68
+ ...args,
69
+ variables: {
70
+ ...usedVariables,
71
+ ...args?.variables
72
+ },
73
+ session
74
+ });
75
+ };
63
76
  if (artifact.kind !== import_types.ArtifactKind.Query || !artifact.refetch?.paginated) {
64
77
  return {
65
78
  artifact,
@@ -2,7 +2,7 @@ import { extractPageInfo } from "$houdini/runtime/lib/pageInfo";
2
2
  import { cursorHandlers, offsetHandlers } from "$houdini/runtime/lib/pagination";
3
3
  import { ArtifactKind } from "$houdini/runtime/lib/types";
4
4
  import React from "react";
5
- import { useClient, useSession } from "../routing/Router";
5
+ import { useClient, useLocation, useSession } from "../routing/Router";
6
6
  function useDocumentHandle({
7
7
  artifact,
8
8
  observer,
@@ -10,6 +10,7 @@ function useDocumentHandle({
10
10
  }) {
11
11
  const [forwardPending, setForwardPending] = React.useState(false);
12
12
  const [backwardPending, setBackwardPending] = React.useState(false);
13
+ const location = useLocation();
13
14
  const [session] = useSession();
14
15
  const client = useClient();
15
16
  const paginationObserver = React.useMemo(() => {
@@ -27,10 +28,22 @@ function useDocumentHandle({
27
28
  return result;
28
29
  };
29
30
  };
30
- const fetchQuery = (args) => observer.send({
31
- ...args,
32
- session
33
- });
31
+ const fetchQuery = (args) => {
32
+ const usedVariables = Object.fromEntries(
33
+ Object.keys(observer.artifact.input?.fields ?? {}).map((fieldName) => [
34
+ fieldName,
35
+ location.params[fieldName]
36
+ ])
37
+ );
38
+ return observer.send({
39
+ ...args,
40
+ variables: {
41
+ ...usedVariables,
42
+ ...args?.variables
43
+ },
44
+ session
45
+ });
46
+ };
34
47
  if (artifact.kind !== ArtifactKind.Query || !artifact.refetch?.paginated) {
35
48
  return {
36
49
  artifact,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini-react",
3
- "version": "0.0.0-20240402041921",
3
+ "version": "0.0.0-20240402042937",
4
4
  "description": "The React plugin for houdini",
5
5
  "keywords": [
6
6
  "typescript",
@@ -43,7 +43,7 @@
43
43
  "recast": "^0.23.1",
44
44
  "rollup": "^3.7.4",
45
45
  "use-deep-compare-effect": "^1.8.1",
46
- "houdini": "^0.0.0-20240402041921"
46
+ "houdini": "^0.0.0-20240402042937"
47
47
  },
48
48
  "files": [
49
49
  "build"