graphile / graphile-engine

Monorepo home of graphile-build, graphile-build-pg, graphile-utils, postgraphile-core and graphql-parse-resolve-info. Build a high-performance easily-extensible GraphQL schema by combining plugins!
https://www.graphile.org/
762 stars 129 forks source link

Error using PG client: "We only support PG clients from a PG pool..." #840

Closed jcalfee closed 1 year ago

jcalfee commented 1 year ago

Summary

This logic assumes I want to use a pool and that I don't have an error handler:

https://github.com/graphile/graphile-engine/blob/68c20b45b6ef2ec5b81a301b489b0eefea26f53f/packages/graphile-build-pg/src/withPgClient.js#L50

Possible Solution

Move this message to the documentation.

jcalfee commented 1 year ago

Possible work-around: client.release = client.end

benjie commented 1 year ago

We only support PG clients from a PG pool. Please use a pool, like it says in the documentation:

https://www.graphile.org/postgraphile/usage-library/#api-postgraphilepgconfig-schemaname-options

You can create a pool with a max size of 1 and grab a client from that if you really want to.

jcalfee commented 1 year ago

I can see now how a max connection of 1 and the pool, instead of the client, can help standardize the code. I just did not see that up-front when I wrote a transactional unit testing libraray..

And, the way I triggered this error was using the createPostGraphileSchema pgConfig documentation "If you already have a client or pool instance, when using this function you may also pass a pg client or a pg-pool instance directly instead of a config." (about https://github.com/graphile/postgraphile/issues/1723)

So, I'll use the work around but plan to move to the pool. That seams to be better anyways. thanks..

benjie commented 1 year ago

Thanks; fixed 👍