Option for location of postgraphile.tags.json5
Feature description
Currently the CLI searches for the postgraphile.tags.json5 file in the working directory.
It would be good addition an option to specify a full path of a configuration file.
Motivating example
The official docker image has the /postgraphile as the working directory.
What if you want to run a container from the official image, but provide your own configuration file.
You could add the configuration file to a volume, and point the execution to a specific path.
It's not possible to mount a volume and just change the container working directory (using -w), because the image command relies on the working directory having all the code.
Breaking changes
The new option would be optional, default to the current behavior. So no breaking change.
Supporting development
I [tick all that apply]:
- [ ] am interested in building this feature myself
- [ ] am interested in collaborating on building this feature
- [x] 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
I have a comment in the code:
https://github.com/graphile/postgraphile/blob/12846c586b314974c4983c65ceaf3cc983614e9a/src/postgraphile/cli.ts#L4-L11
That implies the RC file has to be loaded well before the argument parsing starts.
Here's where the actual import happens:
https://github.com/graphile/postgraphile/blob/12846c586b314974c4983c65ceaf3cc983614e9a/src/postgraphile/postgraphilerc.ts#L4
Perhaps you could make that dependent on an envvar?
postgraphileRCFile = require.resolve(
process.env.POSTGRAPHILE_RC || process.cwd() + '/.postgraphilerc'
);
In V5 we have a graphile.config.ts (or .cjs, .js, .mjs, .cts, ...) file; and you can set the path using the -C option in the graphile command - we should check that there is similar with the pgl and postgraphile commands.