Postgres `sql` command using fetch but not exposing options
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 595
- Forks
- 101
- Avg merge
- 2h 24m
- Merged PRs (30d)
- 1
Description
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:
- Cannot set tags to allow the use of
revalidateTag - 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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the sql template literal integration with @neondatabase/serverless and compare it with the linked vercel-storage example using withFetchOptions. Confirm how fetch options can be exposed per request without changing existing behavior, and verify that callers can set tags and different revalidation conditions for separate queries.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nextjs, postgresql, typescript
- Domain
- api, backend-api-design, databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100