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

Postgres sql command using fetch but not exposing options #671

Open
LukeHosk opened this issue May 1, 2024 · 0 comments
Open

Postgres sql command using fetch but not exposing options #671

LukeHosk opened this issue May 1, 2024 · 0 comments

Comments

@LukeHosk
Copy link

LukeHosk commented May 1, 2024

The sql template literal uses @neondatabase/serverless, which uses fetch. When using this function in Next.js, this causes the result to be automatically cached.

As this function does not expose the fetch options, it is only possible to set them per rout not per-request. This means that (as far as I'm aware) you:

  1. Cannot set tags to allow the use of revalidateTag
  2. Cannot have different revalidation conditions for different requests on the same page (e.g. revalidate a list of comments more often than a blog post)

The neon functions called allow you to pass fetch options, but this library does not (as far as I can tell) provide a way for a developer to provide them.

I created an example of how these options could be passed here. In this example you would have the option of replacing db.sql'...' with db.withFetchOptions(...).sql'...' to set the options used by fetch without altering the behaviour of the original.

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