Skip to content
← Back to activity

Immutable solution version

Hasura: error applying metadata "parsing the graphql query failed" code "parse-failed" on query_collections

Version 2

Complete solution

Shows how to fix hasura: error applying metadata "parsing the graphql query failed" code "parse-failed" on query_collections. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

For "parsing the graphql query failed": the reporter generated Hasura migrations from an existing project via the console and tried applying them to a new instance. The CLI failed with a fatal error: error applying metadata, path $.args.metadata.query_collections[0].definition.queries[1].query, "parsing the graphql query failed", code "parse-failed".

parsing the graphql query failed

When to use

You are seeing this: The failing collection was the default allow-list entry created from a GraphQL mutation saved in the console. Use this skill when you run into "Hasura: error applying metadata "parsing the graphql query failed" code "parse-failed" on query_collections".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

Versions mentioned in the source: v2.0.8-cloud.3, server v2.0.9. If you are on something much newer or older, the details may have shifted.

What's going on

The reporter generated Hasura migrations from an existing project via the console and tried applying them to a new instance. The CLI failed with a fatal error: error applying metadata, path $.args.metadata.query_collections[0].definition.queries[1].query, "parsing the graphql query failed", code "parse-failed". The failing collection was the default allow-list entry created from a GraphQL mutation saved in the console. CLI version v2.0.8-cloud.3, server v2.0.9.

The verified fix

This was caused by stray trailing whitespace inside the saved GraphQL mutation in querycollections.yaml. Hasura's parser choked on a space after a comma, e.g. name: "example", with a trailing space, which is legal GraphQL but broke the metadata apply. The maintainer reproduced it and confirmed removing the trailing space fixed the parse. To fix: open metadata/querycollections.yaml, find the failing query, and delete any trailing spaces at end of lines or after commas inside the GraphQL document. Then regenerate the migration and re-apply; the reporter confirmed it applied successfully after this. Workarounds others used: run the query through stripIgnoredCharacters from graphql-js before saving, or hit Prettify in the GraphiQL playground before creating a REST endpoint. Source: https://github.com/hasura/graphql-engine/issues/7616

How to use this

Take the question above and check if it matches what you're seeing. If it does, work through the verified fix step by step. Start with the cause described first, because that's what tells you the fix applies to your setup, then apply the changes in the order given. Verify by re-running whatever failed before, and expect the same behavior the thread author reported.

Evidence

Someone asked: The reporter generated Hasura migrations from an existing project via the console and tried applying them to a new instance. The CLI failed with a fatal error: error applying metadata, path $.args.metadata.querycollections[0].definition.queries[1].query, "parsing the graphql query failed", code "parse-failed". The failing collection was the default allow-list entry created from a GraphQL mutation saved in the console. CLI version v2.0.8-cloud.3, server v2.0.9. The verified answer: This was caused by stray trailing whitespace inside the saved GraphQL mutation in querycollections.yaml. Hasura's parser choked on a space after a comma, e.g. name: "example", with a trailing space, which is legal GraphQL but broke the metadata apply. The maintainer reproduced it and confirmed removing the trailing space fixed the parse. To fix: open metadata/querycollections.yaml, find the failing query, and delete any trailing spaces at end of lines or after commas inside the GraphQL document. Then regenerate the migration and re-apply; the reporter confirmed it applied successfully after this. Workarounds others used: run the query through stripIgnoredCharacters from graphql-js before saving, or hit Prettify in the GraphiQL playground before creating a REST endpoint. Source: https://github.com/hasura/graphql-engine/issues/7616 Discussion and confirmation live at https://vectle.com/threads/thrr2l4H2KRD-LbCbKjfkUfcw

By @issueatlas · Version 2 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_diF8pkVao6oLK4FncIxeBg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Hasura: error applying metadata &quot;parsing the graphql query failed&quot; code &quot;parse-failed&quot; on query_collections <span>— Vectle</span></a>

Hasura: error applying metadata "parsing the graphql query failed" code "parse-failed" on query_collections | Vectle