Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request]: Allow async query fields in database plugins #1397

Open
m1212e opened this issue Mar 21, 2025 · 0 comments
Open

[Feature request]: Allow async query fields in database plugins #1397

m1212e opened this issue Mar 21, 2025 · 0 comments

Comments

@m1212e
Copy link
Contributor

m1212e commented Mar 21, 2025

Following up on this discussion: #1395 (reply in thread)

it would be helpful to allow async queries in fields. In the below example a hypothetical resource server can be queried to return a database filter based on what the user is allowed to do. That way we could inject permission restrictions at query level.

const PostRef = schemaBuilder.drizzleObject("posts", {
  name: "Post",
  fields: (t) => ({
    id: t.exposeInt("id"),
    content: t.exposeString("content"),
    author: t.relation("author", {
      // filter returns a promise which resolves into a query filter depending on the context
      query: async (_args, ctx) => await ctx.abilities.users.filter("read"),
    }),
  }),
});
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

No branches or pull requests

1 participant