graphql-engine
graphql-engine copied to clipboard
cli: add an alternate filename for config.yaml
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 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
Can we not have a config.yaml file at all then? Can we search for .env
too?
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
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 @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 ashasura-config.yaml
by default from now on. - For backward compatibility, we'll consider
config.yaml
in addition tohasura-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
- --project flag is not set
- --config-file not set
- Normal workflow
cc @arvi3411301
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.
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.
Blocked by #4668
#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.