这是indexloc提供的服务,不要输入任何密码
Skip to content

CLI: Hasura export and auto-apply package produce error without query collections #8787

@sfarley85

Description

@sfarley85

Version Information

Server Version: 2.10
CLI Version (for CLI related issue): 2.8.1

Environment

Local

What is the current behaviour?

I am migrating an existing setup to use metadata/migrations tracking across environments. Locally I setup a new folder for the hasura project and ran hasura export (even though that appears to be redundant as the init set it up). Everything looks to have gone just fine.

Now in my docker compose I've moved to the cli image to automatically apply migrations and metadata on startup. When doing so though I receive this error:

level=fatal msg="error applying metadata \n{\n \"code\": \"parse-failed\",\n \"error\": \"the key 'definition' was not present\",\n \"path\": \"$.args.metadata.query_collections[0]\"\n}"

After looking further it appears this is referring to the query_collections.yaml file, where the hasura export produced one line

- name: allowed-queries

There are no query collections (at least I don't think so, I'm not sure I fully understand what these are but I haven't configured anything by that name and the export didn't populate anything here). Looking elsewhere and at the error it looks like it's now looking for a 'definition' key which will have an object for the all the queries below it. But since I don't have any there is no such key.

If I simply remove this line from the query_collections.yaml (thus rendering the file blank) the server starts without issue and my metadata and migrations appear to all be intact.

Interestingly if I import the metadata in the hasura console it succeeds without issue.

What is the expected behaviour?

I would expect initializing a project's migration and metadata properties could then be applied in reverse using the hasura cli image.

How to reproduce the issue?

  1. Hasura init a project without any query collections
  2. Note if query_collections.yaml has initialized in the metadata folder with a single line - name: allowed-queries
  3. If so, attempt to start an instance using the image hasura/graphql-engine:latest.cli-migrations-v3 . Note the error produced.

Any possible solutions?

As mentioned above removing the generated name key from this file appears to work.

Keywords

metadata-export query-collections cli

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions