hasura / hasura/graphql-engine

AllowList. Strip \r symbol (Windows carriage return) from queries. Make format of queries uniform.

Open
#7,723 0 comments 0 reactions 0 assignees View on GitHub
k/enhancement
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

### Is your proposal related to a problem?

After migration to hasura 2.0.9 and config v3, metadata/query_collections.yaml now has records of differrent formats.

#### Format A - beautiful

```yaml
- name: ADD_MEASURE_TIME
query: |-
mutation ADD_MEASURE_TIME($id: uuid!, $document_type: String!, $meta: jsonb!) {
update_document_by_pk(pk_columns: {document_type: $document_type, id: $id}, _append: {meta: $meta}) {
id
}
}
```

#### Format B - something terrible

```yaml
- name: WIP_GET_CUSTOMS_RESPONSE_BY_ID
query: "subscription GET_CUSTOMS_RESPONSE_BY_ID($file_id: uuid) {\r\n customs_response_data(where:
{file_id: {_eq: $file_id}}) {\r\n file_id\r\n value\r\n meta\r\n
\ dr_no\r\n doc_id\r\n correction_code\r\n }\r\n}\r\n"
```

Note multiple `\r\n` and `\` here.

I suppose it came from queries created by Windows users.

### Describe the solution you'd like

Uniform format for storing queries in db.

Uniform format of metadata export.

Queries always exported with `query: |-`.

No `\r` symbols.

### Describe alternatives you've considered

### If the feature is approved, would you be willing to submit a PR?

I made an attempt to fix queries in the same way as in config v2 but was unsuccesful.

If I come up with workaround - I'll share recipe.

Contributor guide

Open the contributing guide

Research direction

Start by tracing the config v3 metadata export path for query collections and compare it with the example formats in metadata/query_collections.yaml. Done means exported queries use the uniform query: |- format and contain no carriage-return symbols; no specific source file or test is named.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.