Skip to content

Conversation

stevensJourney
Copy link
Collaborator

@stevensJourney stevensJourney commented Sep 9, 2024

Overview

Packages such as the Kysely driver provide a .execute() method on query objects. This execute method could perform pluggable modifications based on installed plugins.

This PR allows the useQuery hooks and composibles from @powersync/react and @powersync/vue to use the execute method from compatible queries.

Related issue: #292

The dialect option in the wrapPowerSyncWithKysely has been made optional since the method provides a PowerSync dialect by default.

Testing

This was verified with unit tests and by implementing a simple Kysely plugin which overwrites the query result.

const k = wrapPowerSyncWithKysely<Database>(db, {
  plugins: [
    {
      transformQuery: (p) => p.node as any,
      transformResult: async (args) => {
        return {
          rows: [{ hello: 's' }]
        };
      }
    }
  ]
});

k.selectFrom('lists')
  .selectAll()
  .execute()
  .then((r) => console.log(`Got test`, r));

image

Copy link

changeset-bot bot commented Sep 9, 2024

🦋 Changeset detected

Latest commit: 53093bc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@powersync/kysely-driver Minor
@powersync/react Patch
@powersync/vue Patch
@powersync/react-native Patch
@powersync/diagnostics-app Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

rkistner
rkistner previously approved these changes Sep 9, 2024
@stevensJourney stevensJourney merged commit c04ecfc into main Sep 9, 2024
5 checks passed
@stevensJourney stevensJourney deleted the fix/usequery-execute branch September 9, 2024 08:23
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.

3 participants