Skip to content

fix(react): use SDK db API in query hook#6

Open
hardikdhingra150 wants to merge 1 commit into
arpitkhandelwal12:mainfrom
hardikdhingra150:fix/react-use-query-sdk-api
Open

fix(react): use SDK db API in query hook#6
hardikdhingra150 wants to merge 1 commit into
arpitkhandelwal12:mainfrom
hardikdhingra150:fix/react-use-query-sdk-api

Conversation

@hardikdhingra150
Copy link
Copy Markdown

Summary

  • fix useQuery to use the public SDK app API: app.db(collectionName)
  • remove the call to unavailable collection.subscribe() and perform a guarded initial load instead
  • refresh query state after insert and remove mutations
  • delete by document _id through the collection filter API
  • type the React context as ZerithDBApp and add a patch changeset for zerithdb-react

Bug Context

The active parent repository has Issues disabled, so I could not open an upstream issue first. I attempted to create one and GitHub returned HTTP 410. The bug is that useQuery treated useZerith() as a raw DbClient with collection(), while createApp() exposes collections through app.db(name). It also attempted to call collection.subscribe(), which is not present on the current CollectionClient implementation.

Validation

  • pnpm exec prettier --check packages/react/src/index.tsx .changeset/fix-react-use-query-sdk-api.md
  • pnpm --filter zerithdb-react build

Note: pnpm --filter zerithdb-react exec tsc --noEmit is currently blocked by existing monorepo path resolution issues in sdk/src imports for sibling package names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant