crystal icon indicating copy to clipboard operation
crystal copied to clipboard

Option for location of postgraphile.tags.json5

Open tuler opened this issue 4 years ago • 2 comments

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

tuler avatar Nov 19 '21 04:11 tuler

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'
  );

benjie avatar Nov 19 '21 11:11 benjie

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.

benjie avatar Oct 04 '23 18:10 benjie