@izumisy-tailor/tailor-data-viewer 0.2.13 → 0.2.14

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@izumisy-tailor/tailor-data-viewer",
3
3
  "private": false,
4
- "version": "0.2.13",
4
+ "version": "0.2.14",
5
5
  "type": "module",
6
6
  "description": "Flexible data viewer component for Tailor Platform",
7
7
  "files": [
@@ -8,10 +8,28 @@ import type {
8
8
  SortState,
9
9
  UseCollectionOptions,
10
10
  UseCollectionReturn,
11
+ ExtractQueryVariables,
11
12
  ValidateCollectionQuery,
12
13
  } from "../types";
13
14
  import type { FieldName, OrderableFieldName } from "../types";
14
15
 
16
+ /**
17
+ * Resolves the variables type for `toQueryArgs()` return value.
18
+ *
19
+ * When the query document carries gql-tada type information
20
+ * (`ExtractQueryVariables` resolves to a concrete type), uses that type
21
+ * so the result is directly compatible with `useQuery()` from urql.
22
+ * Otherwise falls back to `QueryVariables`.
23
+ *
24
+ * Note: The runtime value is always `QueryVariables`, but the gql-tada
25
+ * variables type is structurally compatible (a supertype), so the cast
26
+ * is safe.
27
+ */
28
+ type ResolveVariables<TQuery> =
29
+ ExtractQueryVariables<TQuery> extends never
30
+ ? QueryVariables
31
+ : ExtractQueryVariables<TQuery>;
32
+
15
33
  // -----------------------------------------------------------------------------
16
34
  // Overload signatures
17
35
  // -----------------------------------------------------------------------------
@@ -57,7 +75,7 @@ export function useCollection<
57
75
  FieldName<TMetadata, TTableName>,
58
76
  {
59
77
  query: TQuery;
60
- variables: QueryVariables;
78
+ variables: ResolveVariables<TQuery>;
61
79
  },
62
80
  MetadataFilter<TMetadata, TTableName>
63
81
  >;
@@ -83,7 +101,10 @@ export function useCollection<TQuery>(
83
101
  metadata?: never;
84
102
  tableName?: never;
85
103
  },
86
- ): UseCollectionReturn<string, { query: TQuery; variables: QueryVariables }>;
104
+ ): UseCollectionReturn<
105
+ string,
106
+ { query: TQuery; variables: ResolveVariables<TQuery> }
107
+ >;
87
108
 
88
109
  // -----------------------------------------------------------------------------
89
110
  // Implementation