graphile / graphile/crystal

Support libpq standard environment variables

Open
#3,100 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
12.9k
Forks
625
Avg merge
5h 23m
Merged PRs (30d)
24

Description

### Feature description

I'd like graphile/pgl to support standard postgres environmental variables as defined by libpq. While all of them would be awesome, the high priority ones I'd consider are:

#### Highest Priority
These would allow for immediate, easy dev integration.

- PGHOST
- PGPASSWORD
- PGPORT
- PGDATBASE
- PGUSER
- PGSSLMODE
- PGSERVICE (and ergo pg service files)
-
These would cover most basic interop patterns for devs.

#### Impactful
These would be awesome, but not as strictly required for a use perspective.

- PGOPTIONS
- PGAPPNAME
- PGSSLCERT
- PGPASSFILE

Many of the other non-deprecated ones would also be great.

### Motivating example

Just started using this as a brief example, curious how it works.

I went to the docs and immediately ran a:

`npx pgl -P pgl/amber -e` expecting it to "just work" with my current env var connection. It didnt. I need either go and generate a plain text connection as you want, manually type in all the various cli options to pgl, or write pgl's custom config format.

*This feature makes your tool more adoptable by postgres users & it's ecosystem*

eg:
```bash
# check the db
psql -c "SELECT 1"
# what schema am I in?
psql -c "SHOW search_path"
# awesome, run a migration
./migrate.sh (many db utils support lib pq)
# run our other app server
python some-psycopg-or-asyncpg-app.py
# kill that then run *pgql* 8)

I've seen some trace references to this, but cant find a clear list and after trying for several minutes nothings seems to get it working using _just_ pg env vars.

### Breaking changes

certain pgl / postgraphile command may start a server where as before it wouldnt.

### Supporting development

May be interested if I end up using graphile more in the future, still evaluating

- [ ] 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](https://www.graphile.org/sponsor/) ❤️
- [ ] have an active [support or consultancy contract](https://www.graphile.org/support/) with Graphile

Contributor guide

Open the contributing guide

Research direction

Start at the `npx pgl` CLI entry point and trace how connection settings are currently loaded. Compare that path with the requested libpq variables, prioritizing PGHOST, PGPASSWORD, PGPORT, PGDATABASE, PGUSER, PGSSLMODE, and PGSERVICE. Done means an env-only `npx pgl -P pgl/amber -e` invocation works with the supported variables and existing explicit configuration remains understood.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, postgresql, typescript
Domain
cli, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.