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

Prisma plugin should support async query parameter #971

Open
knpwrs opened this issue Jul 29, 2023 · 1 comment
Open

Prisma plugin should support async query parameter #971

knpwrs opened this issue Jul 29, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@knpwrs
Copy link
Contributor

knpwrs commented Jul 29, 2023

Given the following code:

    playlists: t.relatedConnection('uploadLists', {
      cursor: 'createdAt_id',
      authScopes: privateAuthScopes,
      query: async (_args, context) => {
        const userId = (await context.session)?.appUserId;
        invariant(userId, 'No userId');

        return {
          where: { type: UploadListType.PLAYLIST, author: { id: userId } },
        };
      },
    }),

I get the following error:

image

It would be great if query could be async for when query parameters need to use external resources.

@hayes
Copy link
Owner

hayes commented Jul 29, 2023

This might be possible at some point but adds a lot of complexity/overhead to handle properly. It's critical for performance to allow this to resolve synchronously. It's possible to write the logic that builds the queries to handle this, but doing the simple.thing of just making everything async and using awaits throughout ends up being too inefficient. Open to PRs, but I probably don't have time to look I to something like this until after 4.0 ships

@hayes hayes added the enhancement New feature or request label Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants