Skip to content

Commit

Permalink
0.0.562
Browse files Browse the repository at this point in the history
  • Loading branch information
ivansglazunov committed Sep 23, 2024
1 parent 8227b06 commit 4cda5dd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions imports/client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2638,19 +2638,20 @@ export function useDeepQuery<Table extends 'links'|'numbers'|'strings'|'objects'
return deep._generateQuery<Table>(q, { ...o });
}, [q, o]);
const result = useQuery(wq?.query?.query, { variables: wq?.query?.variables, client: deep.apolloClient, ...o });
const [generatedResult, setGeneratedResult] = useState([]);
const [generated, setGenerated] = useState({ loading: true, data: [] });
useEffect(() => {
if (o?.aggregate) setGeneratedResult((result)?.data?.q0?.aggregate?.[o.aggregate]);
if (o?.aggregate) setGenerated({ loading: false, data: (result)?.data?.q0?.aggregate?.[o.aggregate] });
else {
(async () => {
setGeneratedResult(await deep._generateResult(q, o, result?.data?.q0));
setGenerated({ loading: false, data: await deep._generateResult(q, o, result?.data?.q0) });
})();
}
}, [result]);
const toReturn = {
...result,
originalData: o?.aggregate ? result?.data?.q0?.aggregate : result?.data?.q0,
data: generatedResult,
data: generated.data,
loading: generated.loading,
options: o,
deep,
links: [],
Expand Down Expand Up @@ -2710,21 +2711,22 @@ export function useDeepSubscription<Table extends 'links'|'numbers'|'strings'|'o
return deep._generateQuery(q, { ...o, subscription: true });
}, [q, o]);
const result = useSubscription(wq?.query?.query, { variables: wq?.query?.variables, client: deep.apolloClient, ...o });
const [generatedResult, setGeneratedResult] = useState([]);
const [generated, setGenerated] = useState({ loading: true, data: [] });
useEffect(() => {
if (o?.aggregate) setGeneratedResult((result)?.data?.q0?.aggregate?.[o.aggregate]);
if (o?.aggregate) setGenerated({ loading: false, data: (result)?.data?.q0?.aggregate?.[o.aggregate] });
else {
if (!result.loading) {
(async () => {
setGeneratedResult(await deep._generateResult(q, o, result?.data?.q0));
setGenerated({ loading: false, data: await deep._generateResult(q, o, result?.data?.q0) });
})();
}
}
}, [result]);
const toReturn = {
...result,
originalData: o?.aggregate ? result?.data?.q0?.aggregate : result?.data?.q0,
data: generatedResult,
data: generated.data,
loading: generated.loading,
options: o,
deep,
links: [],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@deep-foundation/deeplinks",
"version": "0.0.561",
"version": "0.0.562",
"license": "Unlicense",
"type": "module",
"main": "import.js",
Expand Down

0 comments on commit 4cda5dd

Please sign in to comment.