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.js pool support #441

Open
4 of 6 tasks
DanielFGray opened this issue Mar 2, 2024 · 3 comments
Open
4 of 6 tasks

postgres.js pool support #441

DanielFGray opened this issue Mar 2, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@DanielFGray
Copy link

DanielFGray commented Mar 2, 2024

Feature description

I think Worker should ideally be able to accept a pool from either node-postgres or postgres.js

Motivating example

I am currently working on a project that connects to the db using postgres.js, my app does not use node-postgres anywhere, and ideally I shouldn't be required to add another adapter.

Breaking changes

I don't believe this should constitute a breaking change

Supporting development

I [tick all that apply]:

  • am interested in building this feature myself
  • am interested in collaborating on building this feature
  • am willing to help testing this feature before it's released
  • am willing to write a test-driven test suite for this feature (before it exists)
  • am a Graphile sponsor ❤️
  • have an active support or consultancy contract with Graphile
@DanielFGray
Copy link
Author

Happy to help where I can on this, though I fear my attempt wouldn't quite be up to par with the usual Graphile standards

@benjie
Copy link
Member

benjie commented Mar 2, 2024

Ideally we'd use an adaptor system like with PostGraphile V5 (or, more specifically, @dataplan/pg) such that we can use any client for which there is an adaptor. We have graphile-config for config, and @graphile/logger for logging, so we should probably extract the adaptors from @dataplan/pg and make @graphile/pg or similar that all our projects can use. In the mean time, we use very few of the Postgres methods, so you could probably create a stub pool/client combo with anything that quacks sufficiently like Pool/Client that we'd believe that's what it was. Pool.connect/Pool.end/Pool.on('error')/Pool.on('connect') and PoolClient.query/PoolClient.on('error')/PoolClient.on('notification') are the main things I can think of off-hand.

@DanielFGray
Copy link
Author

DanielFGray commented Mar 21, 2024

for whatever it's worth (and mostly to anyone else who might stumble on this issue), I found postgres-bridge which I expected to stub the necessary bits, but I would get either TypeError: pgPool.query is not a function or TypeError: pgPool.connect is not a function depending on if I pass the bridge instance directly as a pool, or the result of await bridge.connect() and I couldn't quite narrow it down any further

for now, sticking with using pg for worker and postgres for everything else

@benjie benjie added the enhancement New feature or request label Apr 26, 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