deep-foundation / deep-foundation/deeplinks

useDeepSubscription returns empty array while deep.select finds the link with the same query

Open
#162 2 comments 0 reactions 1 assignee Claimed by @FreePhoenix888 View on GitHub
bug
Dominant language
TypeScript
Stars
13
Forks
8
PR merge metrics
No merged PRs in 30d

Description

# useDeepSubscription
## Code
```ts
const { data, loading, error } = useDeepSubscription({
type_id: {
_id: ['@deep-foundation/core', 'Package'],
},
string: {
value: DEEP_MEMO_PACKAGE_NAME,
},
});
useEffect(() => {
console.log({data, loading, error})
}, [data, loading, error]);
```
## Result:
![image](https://user-images.githubusercontent.com/66206278/234321181-e0110105-1580-4134-9e3a-b7be2eebdd17.png)

# Deep.select
## Code
```ts
await deep.select({
"type_id": {
"_id": [
"@deep-foundation/core",
"Package"
]
},
"string": {
"value": "@deep-foundation/deep-memo"
}
})
```
## Result
![image](https://user-images.githubusercontent.com/66206278/234321030-52ad4d39-8105-4c14-8fb6-decc2adcf988.png)

# My tries to find fix
## Explicit table and returning
### Code
```ts
const { data, loading, error } = useDeepSubscription({
type_id: {
_id: ['@deep-foundation/core', 'Package'],
},
// string: {
// value: DEEP_MEMO_PACKAGE_NAME,
// },
},{table: 'links', returning: deep.linksSelectReturning});
useEffect(() => {
console.log({data, loading, error})
}, [data, loading, error]);
```
### Result
The same behavior - empty data property in the result object

# Test
## Code
https://github.com/deep-foundation/dev/blob/e16471ddfe06e46b200b1c7e7a446487f10e707a/tests/client.tsx#L467
## Result
```ts
● client › useDeepSubscription › type

expect(received).toBeGreaterThan(expected)

Expected: > 0
Received: 0

478 | const dataLengthText = screen.getByText(/items loaded$/);
479 | const dataLength = parseInt(dataLengthText.textContent);
> 480 | expect(dataLength).toBeGreaterThan(0);
| ^
481 |
482 | async function setup() {
483 | const typeTypeLinkId = await deepClient.id("@deep-foundation/core", "Type");

at tests/client.tsx:480:26
at fulfilled (tests/client.tsx:5:58)
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.