houdini-react 0.0.0-20240311071844 → 0.0.0-20240328033602

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.
@@ -77807,7 +77807,7 @@ function processComponentFieldDirective(directive) {
77807
77807
  export: exportValue
77808
77808
  };
77809
77809
  }
77810
- function unwrapType(config, type, wrappers = []) {
77810
+ function unwrapType(config, type, wrappers = [], convertRuntimeScalars) {
77811
77811
  if (type.kind === "NonNullType") {
77812
77812
  return unwrapType(config, type.type, [TypeWrapper.NonNull, ...wrappers]);
77813
77813
  }
@@ -77823,7 +77823,7 @@ function unwrapType(config, type, wrappers = []) {
77823
77823
  if (type instanceof graphql3.GraphQLList) {
77824
77824
  return unwrapType(config, type.ofType, [TypeWrapper.List, ...wrappers]);
77825
77825
  }
77826
- if (config.configFile.features?.runtimeScalars?.[type.name.value]) {
77826
+ if (convertRuntimeScalars && config.configFile.features?.runtimeScalars?.[type.name.value]) {
77827
77827
  type = config.schema.getType(
77828
77828
  config.configFile.features?.runtimeScalars?.[type.name.value].type
77829
77829
  );
@@ -78700,6 +78700,7 @@ async function walk_routes(args) {
78700
78700
  async function add_view(args) {
78701
78701
  const target = args.type === "page" ? args.project.pages : args.project.layouts;
78702
78702
  const queries = await extractQueries(args.contents);
78703
+ console.log({ queries });
78703
78704
  const missing_queries = queries.filter((query2) => !args.queries.includes(query2));
78704
78705
  if (missing_queries.length > 0) {
78705
78706
  throw {
@@ -78741,7 +78742,7 @@ async function add_query(args) {
78741
78742
  });
78742
78743
  const queryVariables = Object.fromEntries(
78743
78744
  query2.variableDefinitions?.map((variable) => {
78744
- const { type, wrappers } = unwrapType(args.config, variable.type);
78745
+ const { type, wrappers } = unwrapType(args.config, variable.type, [], true);
78745
78746
  return [
78746
78747
  variable.variable.name.value,
78747
78748
  { wrappers, type: type.name }
@@ -78809,7 +78810,15 @@ async function extractQueries(source) {
78809
78810
  } else {
78810
78811
  return [];
78811
78812
  }
78812
- return props.filter((p) => p !== "children");
78813
+ return props.reduce((queries, query2) => {
78814
+ if (query2 === "children") {
78815
+ return queries;
78816
+ }
78817
+ if (query2.endsWith("$handle")) {
78818
+ query2 = query2.substring(0, query2.length - "$handle".length);
78819
+ }
78820
+ return queries.concat([query2]);
78821
+ }, []);
78813
78822
  }
78814
78823
  function isSecondaryBuild() {
78815
78824
  return process.env.HOUDINI_SECONDARY_BUILD && process.env.HOUDINI_SECONDARY_BUILD !== "false";
@@ -77797,7 +77797,7 @@ function processComponentFieldDirective(directive) {
77797
77797
  export: exportValue
77798
77798
  };
77799
77799
  }
77800
- function unwrapType(config, type, wrappers = []) {
77800
+ function unwrapType(config, type, wrappers = [], convertRuntimeScalars) {
77801
77801
  if (type.kind === "NonNullType") {
77802
77802
  return unwrapType(config, type.type, [TypeWrapper.NonNull, ...wrappers]);
77803
77803
  }
@@ -77813,7 +77813,7 @@ function unwrapType(config, type, wrappers = []) {
77813
77813
  if (type instanceof graphql3.GraphQLList) {
77814
77814
  return unwrapType(config, type.ofType, [TypeWrapper.List, ...wrappers]);
77815
77815
  }
77816
- if (config.configFile.features?.runtimeScalars?.[type.name.value]) {
77816
+ if (convertRuntimeScalars && config.configFile.features?.runtimeScalars?.[type.name.value]) {
77817
77817
  type = config.schema.getType(
77818
77818
  config.configFile.features?.runtimeScalars?.[type.name.value].type
77819
77819
  );
@@ -78690,6 +78690,7 @@ async function walk_routes(args) {
78690
78690
  async function add_view(args) {
78691
78691
  const target = args.type === "page" ? args.project.pages : args.project.layouts;
78692
78692
  const queries = await extractQueries(args.contents);
78693
+ console.log({ queries });
78693
78694
  const missing_queries = queries.filter((query2) => !args.queries.includes(query2));
78694
78695
  if (missing_queries.length > 0) {
78695
78696
  throw {
@@ -78731,7 +78732,7 @@ async function add_query(args) {
78731
78732
  });
78732
78733
  const queryVariables = Object.fromEntries(
78733
78734
  query2.variableDefinitions?.map((variable) => {
78734
- const { type, wrappers } = unwrapType(args.config, variable.type);
78735
+ const { type, wrappers } = unwrapType(args.config, variable.type, [], true);
78735
78736
  return [
78736
78737
  variable.variable.name.value,
78737
78738
  { wrappers, type: type.name }
@@ -78799,7 +78800,15 @@ async function extractQueries(source) {
78799
78800
  } else {
78800
78801
  return [];
78801
78802
  }
78802
- return props.filter((p) => p !== "children");
78803
+ return props.reduce((queries, query2) => {
78804
+ if (query2 === "children") {
78805
+ return queries;
78806
+ }
78807
+ if (query2.endsWith("$handle")) {
78808
+ query2 = query2.substring(0, query2.length - "$handle".length);
78809
+ }
78810
+ return queries.concat([query2]);
78811
+ }, []);
78803
78812
  }
78804
78813
  function isSecondaryBuild() {
78805
78814
  return process.env.HOUDINI_SECONDARY_BUILD && process.env.HOUDINI_SECONDARY_BUILD !== "false";
@@ -10,6 +10,7 @@ export declare function useDocumentHandle<_Artifact extends QueryArtifact, _Data
10
10
  export type DocumentHandle<_Artifact extends QueryArtifact, _Data extends GraphQLObject = GraphQLObject, _Input extends GraphQLVariables = GraphQLVariables> = {
11
11
  data: _Data;
12
12
  partial: boolean;
13
+ fetch: FetchFn<_Data, _Input>;
13
14
  } & RefetchHandlers<_Artifact, _Data, _Input>;
14
15
  type RefetchHandlers<_Artifact extends QueryArtifact, _Data extends GraphQLObject, _Input> = _Artifact extends {
15
16
  refetch: {
@@ -5,6 +5,7 @@ import { GraphQLObject, GraphQLVariables } from '$houdini/runtime/lib/types';
5
5
  import { QueryArtifact } from '$houdini/runtime/lib/types';
6
6
  import type { RouterManifest } from '$houdini/runtime/router/types';
7
7
  import React from 'react';
8
+ import { DocumentHandle } from '../hooks/useDocumentHandle';
8
9
  import { SuspenseCache } from './cache';
9
10
  type ComponentType = any;
10
11
  /**
@@ -54,7 +55,7 @@ export declare function useCache(): Cache;
54
55
  export declare function updateLocalSession(session: App.Session): void;
55
56
  export declare function useSession(): [App.Session, (newSession: Partial<App.Session>) => void];
56
57
  export declare function useCurrentVariables(): GraphQLVariables;
57
- export declare function useQueryResult<_Data extends GraphQLObject, _Input extends GraphQLVariables>(name: string): [_Data | null, DocumentStore<_Data, _Input>];
58
+ export declare function useQueryResult<_Data extends GraphQLObject, _Input extends GraphQLVariables>(name: string): [_Data | null, DocumentHandle<any, _Data, _Input>];
58
59
  export type RouterCache = {
59
60
  artifact_cache: SuspenseCache<QueryArtifact>;
60
61
  component_cache: SuspenseCache<(props: any) => React.ReactElement>;
@@ -10,6 +10,7 @@ export declare function useDocumentHandle<_Artifact extends QueryArtifact, _Data
10
10
  export type DocumentHandle<_Artifact extends QueryArtifact, _Data extends GraphQLObject = GraphQLObject, _Input extends GraphQLVariables = GraphQLVariables> = {
11
11
  data: _Data;
12
12
  partial: boolean;
13
+ fetch: FetchFn<_Data, _Input>;
13
14
  } & RefetchHandlers<_Artifact, _Data, _Input>;
14
15
  type RefetchHandlers<_Artifact extends QueryArtifact, _Data extends GraphQLObject, _Input> = _Artifact extends {
15
16
  refetch: {
@@ -5,6 +5,7 @@ import { GraphQLObject, GraphQLVariables } from '$houdini/runtime/lib/types';
5
5
  import { QueryArtifact } from '$houdini/runtime/lib/types';
6
6
  import type { RouterManifest } from '$houdini/runtime/router/types';
7
7
  import React from 'react';
8
+ import { DocumentHandle } from '../hooks/useDocumentHandle';
8
9
  import { SuspenseCache } from './cache';
9
10
  type ComponentType = any;
10
11
  /**
@@ -54,7 +55,7 @@ export declare function useCache(): Cache;
54
55
  export declare function updateLocalSession(session: App.Session): void;
55
56
  export declare function useSession(): [App.Session, (newSession: Partial<App.Session>) => void];
56
57
  export declare function useCurrentVariables(): GraphQLVariables;
57
- export declare function useQueryResult<_Data extends GraphQLObject, _Input extends GraphQLVariables>(name: string): [_Data | null, DocumentStore<_Data, _Input>];
58
+ export declare function useQueryResult<_Data extends GraphQLObject, _Input extends GraphQLVariables>(name: string): [_Data | null, DocumentHandle<any, _Data, _Input>];
58
59
  export type RouterCache = {
59
60
  artifact_cache: SuspenseCache<QueryArtifact>;
60
61
  component_cache: SuspenseCache<(props: any) => React.ReactElement>;
@@ -46,6 +46,7 @@ var import_scalars = require("$houdini/runtime/lib/scalars");
46
46
  var import_match = require("$houdini/runtime/router/match");
47
47
  var import_react = __toESM(require("react"));
48
48
  var import_react2 = require("react");
49
+ var import_useDocumentHandle = require("../hooks/useDocumentHandle");
49
50
  var import_useDocumentStore = require("../hooks/useDocumentStore");
50
51
  var import_cache = require("./cache");
51
52
  const PreloadWhich = {
@@ -392,15 +393,23 @@ const LocationContext = import_react.default.createContext({
392
393
  params: {}
393
394
  });
394
395
  function useQueryResult(name) {
395
- const store_ref = useRouterContext().data_cache.get(name);
396
- const [{ data, errors }, observer] = (0, import_useDocumentStore.useDocumentStore)({
396
+ const { data_cache, artifact_cache } = useRouterContext();
397
+ const store_ref = data_cache.get(name);
398
+ const [storeValue, observer] = (0, import_useDocumentStore.useDocumentStore)({
397
399
  artifact: store_ref.artifact,
398
400
  observer: store_ref
399
401
  });
402
+ const { data, errors } = storeValue;
400
403
  if (errors && errors.length > 0) {
401
404
  throw new Error(JSON.stringify(errors));
402
405
  }
403
- return [data, observer];
406
+ const artifact = artifact_cache.get(name);
407
+ const handle = (0, import_useDocumentHandle.useDocumentHandle)({
408
+ artifact,
409
+ observer,
410
+ storeValue
411
+ });
412
+ return [data, handle];
404
413
  }
405
414
  function useLinkBehavior({
406
415
  goto,
@@ -10,6 +10,7 @@ export declare function useDocumentHandle<_Artifact extends QueryArtifact, _Data
10
10
  export type DocumentHandle<_Artifact extends QueryArtifact, _Data extends GraphQLObject = GraphQLObject, _Input extends GraphQLVariables = GraphQLVariables> = {
11
11
  data: _Data;
12
12
  partial: boolean;
13
+ fetch: FetchFn<_Data, _Input>;
13
14
  } & RefetchHandlers<_Artifact, _Data, _Input>;
14
15
  type RefetchHandlers<_Artifact extends QueryArtifact, _Data extends GraphQLObject, _Input> = _Artifact extends {
15
16
  refetch: {
@@ -5,6 +5,7 @@ import { GraphQLObject, GraphQLVariables } from '$houdini/runtime/lib/types';
5
5
  import { QueryArtifact } from '$houdini/runtime/lib/types';
6
6
  import type { RouterManifest } from '$houdini/runtime/router/types';
7
7
  import React from 'react';
8
+ import { DocumentHandle } from '../hooks/useDocumentHandle';
8
9
  import { SuspenseCache } from './cache';
9
10
  type ComponentType = any;
10
11
  /**
@@ -54,7 +55,7 @@ export declare function useCache(): Cache;
54
55
  export declare function updateLocalSession(session: App.Session): void;
55
56
  export declare function useSession(): [App.Session, (newSession: Partial<App.Session>) => void];
56
57
  export declare function useCurrentVariables(): GraphQLVariables;
57
- export declare function useQueryResult<_Data extends GraphQLObject, _Input extends GraphQLVariables>(name: string): [_Data | null, DocumentStore<_Data, _Input>];
58
+ export declare function useQueryResult<_Data extends GraphQLObject, _Input extends GraphQLVariables>(name: string): [_Data | null, DocumentHandle<any, _Data, _Input>];
58
59
  export type RouterCache = {
59
60
  artifact_cache: SuspenseCache<QueryArtifact>;
60
61
  component_cache: SuspenseCache<(props: any) => React.ReactElement>;
@@ -5,6 +5,7 @@ import { marshalSelection, marshalInputs } from "$houdini/runtime/lib/scalars";
5
5
  import { find_match } from "$houdini/runtime/router/match";
6
6
  import React from "react";
7
7
  import { useContext } from "react";
8
+ import { useDocumentHandle } from "../hooks/useDocumentHandle";
8
9
  import { useDocumentStore } from "../hooks/useDocumentStore";
9
10
  import { suspense_cache } from "./cache";
10
11
  const PreloadWhich = {
@@ -351,15 +352,23 @@ const LocationContext = React.createContext({
351
352
  params: {}
352
353
  });
353
354
  function useQueryResult(name) {
354
- const store_ref = useRouterContext().data_cache.get(name);
355
- const [{ data, errors }, observer] = useDocumentStore({
355
+ const { data_cache, artifact_cache } = useRouterContext();
356
+ const store_ref = data_cache.get(name);
357
+ const [storeValue, observer] = useDocumentStore({
356
358
  artifact: store_ref.artifact,
357
359
  observer: store_ref
358
360
  });
361
+ const { data, errors } = storeValue;
359
362
  if (errors && errors.length > 0) {
360
363
  throw new Error(JSON.stringify(errors));
361
364
  }
362
- return [data, observer];
365
+ const artifact = artifact_cache.get(name);
366
+ const handle = useDocumentHandle({
367
+ artifact,
368
+ observer,
369
+ storeValue
370
+ });
371
+ return [data, handle];
363
372
  }
364
373
  function useLinkBehavior({
365
374
  goto,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini-react",
3
- "version": "0.0.0-20240311071844",
3
+ "version": "0.0.0-20240328033602",
4
4
  "description": "The React plugin for houdini",
5
5
  "keywords": [
6
6
  "typescript",
@@ -37,13 +37,13 @@
37
37
  "express": "^4.18.2",
38
38
  "graphql": "^15.8.0",
39
39
  "graphql-yoga": "^4.0.4",
40
- "react": "18.3.0-canary-09fbee89d-20231013",
41
- "react-dom": "18.3.0-canary-09fbee89d-20231013",
40
+ "react": "19.0.0-canary-2b036d3f1-20240327",
41
+ "react-dom": "19.0.0-canary-2b036d3f1-20240327",
42
42
  "react-streaming-compat": "^0.3.18",
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-20240311071844"
46
+ "houdini": "^0.0.0-20240328033602"
47
47
  },
48
48
  "files": [
49
49
  "build"