-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AllowList parsing error when exporting metadata #7616
Comments
Can you share the contents of I have a hunch this is related to #7608 |
Hi,
|
Please wrap the code in 3 backticks, and add the proper formatting, so github does not alter the code: ```yaml your:
yaml:
- code: "here" ``` Either way, it's weird that the mutation is a json string, while the query is a yaml multiline string... |
No, i haven't done any change in it. |
Can you try with this file, and let us know the results? - name: allowed-queries
definition:
queries:
- name: getCompanies
query: |-
query MyQuery {
company {
company_addresses {
address {
address_line_1
address_line_2
city
country
postal_code
state
}
}
id
name
}
}
- name: addCompany
query: |-
mutation MyQuery {
insert_company(objects: {
company_addresses: {
data: {
id: "94909f0b-e9db-4ce6-809b-0de59463caf1",
address: {
data: {
address_line_1: "16, swastik circle",
address_line_2: "",
city: "Ahmedabad",
country: "india",
id: "1354fd0e-cb95-49ae-97d4-9ebfa225e831",
postal_code: "312203",
state: "Gujarat"
},
on_conflict: {constraint: address_pkey}
}
}
},
name: "cygnet",
id: "81c20bdf-fc22-473b-9ffb-173f4d6c6da2"
}) {
affected_rows
}
} Edit: Accidentally send invalid file, corrected, please try again |
I tried above in query_collection meta data but now i am getting different error. time="2021-09-30T13:18:24+05:30" level=fatal msg="error applying metadata \n{\n "path": "$.args.metadata.query_collections[0].definition",\n "error": "When parsing the constructor CollectionDef of type Hasura.RQL.Types.QueryCollection.CollectionDef expected Object but got Null.",\n "code": "parse-failed"\n}" |
|
I tried that updated file, now i am getting following error. time="2021-09-30T13:25:38+05:30" level=fatal msg="error applying metadata \n{\n "path": "$.args.metadata.query_collections[0].definition.queries[1].query",\n "error": "parsing the graphql query failed",\n "code": "parse-failed"\n}" |
That's the same error as before, meaning this isn't related to how the string is stored in the metadata file. |
I've managed to narrow down this bug, it's some kind of very weird parsing error. - name: allowed-queries
definition:
queries:
- name: InsertUser
query: |-
mutation InsertUser {
insert_user(objects: {
username: "",
password: "81c20bdf-fc22-473b-9ffb-173f4d6c6da"
}) {
affected_rows
}
} Importantly, there is a space after |
I am facing issue in migrating db also. |
You are attempting to apply a migration that already exists on the database. Your migration state may be inconsistent. |
Hey @niveditavijayvargiya, as @BenoitRanque stated in #7616 (comment) the issue occurred because of space and we aren't able to produce this metadata in v2.0.9. It would be great if you can mention the versions of cli and server i.e the output of |
@purush7 I can reproduce this on 2.0.9 as both server and cli version |
@BenoitRanque Did you get metadata with spaces from server v2.0.9 |
Oh my bad, no what I meant was I get a parsing error with the document I posted above, which looks valid |
I am using cli version v2.0.8-cloud.3. This issue occur only i have that mutation query, if i remove this mutation end point then it allows me to migrate. |
@niveditavijayvargiya you should be able to remove the space after |
We want to add this flow in our cicd pipeline, when this issue can be resolved? Can you please help me on it? |
Hey @niveditavijayvargiya , Did you added the allow-list by uploading the graphql file or manually? |
No, i haven't added anything manually. I just created one instance in Hasura, added database from AWS RDS, added some rest endpoint with graph ql queries in it. After that i have created migration from this instance and try to apply those migration to another instance. |
Hey @niveditavijayvargiya, how did you added the allow-list which I cannot see that in above process? |
BTW the error has been occurred due to the space which is present in the query itself |
No, i haven't added. Its default one only. Ok, Let me check for space in my query. |
I haven't added allow list. Is it mandatory for migrations? Sorry i am new to Hasura. |
mutation MyQuery {
insert_company(objects: {
company_addresses: {
data: {
id: "94909f0b-e9db-4ce6-809b-0de59463caf1",
address: {
data: {
address_line_1: "16, swastik circle",
address_line_2: "",
city: "Ahmedabad",
country: "india",
id: "1354fd0e-cb95-49ae-97d4-9ebfa225e831",
postal_code: "312203",
state: "Gujarat"
},
on_conflict: {constraint: address_pkey}
}
}
},
name: "cygnet",
id: "81c20bdf-fc22-473b-9ffb-173f4d6c6da2"
}) {
affected_rows
}
} you have spaces after
|
It's not mandatory. It restricts your project’s GraphQL Engine to execute only queries that are present in the allowlist. you can find the info about |
@niveditavijayvargiya remove the spaces which I mentioned in #7616 (comment) and try to apply the metadata |
@niveditavijayvargiya Is the problem solved? |
Yes Thanks. After removing extra space from my mutation query and regenerated migration so its started working. Migration applied successfully. Still can you please fix that issue even graph ql query have any spaces at the end then while generating yaml file this space should be trimmed. It will be helpful approach as graph ql syntax allow such spaces but its Yaml syntax which create issue in case of extra spaces. Sometime while beautify code for proper reading such spaces can be added in graph ql. |
Got hit this today. Resolved it with stripIgnoredCharacters from graphql-js graphql/graphql-js#1802. So before inserting queries thorough metatadata api I clean them with stripIgnoredCharacters. Then the metadata export works fine. Maybe hasura could store queries similarly and only prettyprint them in admin console |
For anyone else having this same issue, If Hasura can prettify all the queries automatically before adding to the file, it would fix this whole issue. |
I have generated my migrations using hasura console from existing project and its worked fine. Now i have created new project and i want to migrate my migrations to new instance its throwing error like issue in meta data and parsing failed.
time="2021-09-30T11:24:54+05:30" level=fatal msg="error applying metadata \n{\n "path": "$.args.metadata.query_collections[0].definition.queries[1].query",\n "error": "parsing the graphql query failed",\n "code": "parse-failed"\n}"
The text was updated successfully, but these errors were encountered: