graphql-engine icon indicating copy to clipboard operation
graphql-engine copied to clipboard

cli: add an alternate filename for config.yaml

Open shahidhk opened this issue 4 years ago • 9 comments

Couple of our users have mentioned that config.yaml is too generic. We cannot remove the support for config.yaml, but we can introduce an optional new file hasura-config.yaml which can be selected by using a flag on the init command.

Later we could probably make it a default too.

The function which validates a folder to be a Hasura Project will need to be updated accordingly.

shahidhk avatar Apr 25 '20 07:04 shahidhk

@shahidhk a couple of thoughts,

Instead of adding a new flag to init, I am thinking of an alternate approach. We can have a top-level flag called --config-file, Which a user can use to specify the path to the config file. The default config locations can be be config.yaml and hasura-config.yaml.

This can also account for a use case like,

hasura migrate apply --config-file /some/path/myconfig.yaml

What do you think ?

cc @arvi3411301

scriptonist avatar Apr 30 '20 06:04 scriptonist

Can we not have a config.yaml file at all then? Can we search for .env too?

shahidhk avatar Apr 30 '20 10:04 shahidhk

I think leaving both config.yaml and .env has some use. I can use config.yaml to store all keys that i would like to be shared and put it in version control and use the .env for things that should be private e.g admin-secret

rikinsk avatar Apr 30 '20 12:04 rikinsk

The top level --config-file flag make sense. But if we choose to support multiple default config files (eg- config.yaml and hasura-config.yaml), we will have to define a flag on init command to select which config file to populate the directory with.

I think removing config.yaml is possible if the user gives --config-file with each command they run (to locate the execution directory) or else we allow running commands only from hasura project's root directory. A default config file helps avoid both of the above situations.

shraddhaag avatar Apr 30 '20 14:04 shraddhaag

@ShraddhaAg @rikinsk @shahidhk Just to make sure I'm getting this across, this is what I'm thinking.

hasura init

  • During init we can make the CLI generate config file as hasura-config.yaml by default from now on.
  • For backward compatibility, we'll considerconfig.yaml in addition to hasura-config.yaml as the default config filename.

--config-file

  • --config-file flag is set
    • --project flag is not set
      • The parent directory of config file path can be considered as the project directory.
    • --project flag is set
      • respect this flag
  • --config-file not set
    • Normal workflow

cc @arvi3411301

scriptonist avatar May 04 '20 05:05 scriptonist

This sounds good.

Do we need both config-file bad project flags? Provided we're giving plenty of choices (config.yaml, hasura-config.yaml, .env), another flag for it seems overkill.

Also, by getting the project directory directly, we don't have to find the project root.

shahidhk avatar May 04 '20 06:05 shahidhk

It makes sense to have a--project flag for now @shahidhk. For config V2 the only file required to consider a directory as a project directory is config.yaml all other things are configurable. So I was thinking keeping the config file as context.

Other Suggestions
  • Introducing --config-file flag and deprecating --project
  • @arvi3411301 suggested having a flag which can accept both a config file / a project directory rather than having separate ones for both.

scriptonist avatar May 05 '20 03:05 scriptonist

Blocked by #4668

shraddhaag avatar May 07 '20 06:05 shraddhaag

#4668 has been open for over a year and a half now. Is there any path to getting it resolved and merged or getting the --config-file option added?

It is annoying that Hasura has decided to dictate entirely file structure rather than allowing developers to decide on our own how to structure our repositories.

Garbee avatar Dec 30 '21 22:12 Garbee