I have a remote_schemas.yaml file:
- name: api
definition:
url: "{{ API_GRAPHQL_ENDPOINT }}"
timeout_seconds: 60
based on the docs here: https://hasura.io/blog/moving-from-local-development-staging-production-with-hasura/. I have the `` environment variable set, but the hasura CLI is still not happy:
❯ API_GRAPHQL_ENDPOINT=https://7asdf8.ngrok.io/graphql hasura metadata apply --admin-secret $HASURA_GRAPHQL_ADMIN_SECRET
FATA[0005] failed to apply metadata: cannot apply metadata on the database: [parse-failed] not a valid URI ($[1].remote_schemas[0].definition.url)
And dropping the quotes
url: {{ API_GRAPHQL_ENDPOINT }}
doesn't work either:
❯ API_GRAPHQL_ENDPOINT=https://7asdf8.ngrok.io/graphql hasura metadata apply --admin-secret $HASURA_GRAPHQL_ADMIN_SECRET
FATA[0004] failed to apply metadata: cannot apply metadata on the database: yaml: invalid map key: map[interface {}]interface {}{"API_GRAPHQL_ENDPOINT":interface {}(nil)}
Also doesn't work:
url: ${API_GRAPHQL_ENDPOINT}
and
url: $API_GRAPHQL_ENDPOINT
Should be
- name: api
definition:
url_from_env: API_GRAPHQL_ENDPOINT
For remote schemas, the metadata doesn't support `{{ }}`` style env templating yet. Pls see this issue for that feature: https://github.com/hasura/graphql-engine/issues/2483
For remote schemas, the metadata doesn't support `{{ }}`` style env templating yet. Pls see this issue for that feature: #2483
For that the env var has to exist on the server (where hasura is running). Is there a way to only have it defined for the cli (using .env file for example) and then be replaced during the metadata apply? Like templating?
To elaborate on @John0x' comment—we keep prod/dev/test migrations separate from the infrastructure that sets up Hasura on AWS Fargate. We also have separate remote schema URLs for prod/dev/test. We need to be able to set those URLs in the metadata without redeploying/modifying the infrastructure repository.
The ideal way would be to run hasura metadata apply from the migration repository with the URLs set as environment variables on the machine running the hasura cli. Any thoughts on how we could achieve this?
Edit: For now, we use cat metadata/remote_schemas.yaml | envsubst '$PREVIEW_GRAPHQL_ENDPOINT' | tee temp.yaml && mv temp.yaml metadata/remote_schemas.yaml before runnning hasura metadata apply
This is a very important feature for us as well.
Any ETA for enabling it?
Most helpful comment
To elaborate on @John0x' comment—we keep prod/dev/test migrations separate from the infrastructure that sets up Hasura on AWS Fargate. We also have separate remote schema URLs for prod/dev/test. We need to be able to set those URLs in the metadata without redeploying/modifying the infrastructure repository.
The ideal way would be to run
hasura metadata applyfrom the migration repository with the URLs set as environment variables on the machine running the hasura cli. Any thoughts on how we could achieve this?Edit: For now, we use
cat metadata/remote_schemas.yaml | envsubst '$PREVIEW_GRAPHQL_ENDPOINT' | tee temp.yaml && mv temp.yaml metadata/remote_schemas.yamlbefore runnninghasura metadata apply