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

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.

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