-
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
Graphql error: enum type does not exist because case sensitivity was not recognized #4014
Comments
Did you find any solution to this? |
@perrosnk No. I've just been manually renaming the enum to lower case in Postgres to get past the problem. |
I am trying to reproduce this issue, so that I can create a minimum working example of this, and figure out what is happening here. Could you please tell me some details?
|
Refer to enums in the hasura graphql engine section of the documentation. You may have to copy native PG enum types to referenced tables approach. After that alter existing column to TEXT data type and add foreign key to the new referenced table. |
This should be as simple as ensuring that the enum type name is wrapped in double quotes. |
@ravikiran438 This is a bug. If the enum name contains an uppercase letter, it will be flattened to lowercase and then this error will appear. We had |
hey folks, thanks for your patience. We'll be triaging this bug shortly. I believe I'm able to reproduce with the following setup on v2.3.1. Please take a look and let me know if this seems like a reasonable minimal repro, or if I've missed anything compared to the original bug report? DDL statements on a Postgres DB, using example from Hasura docs CREATE TABLE MixedCase (
value text PRIMARY KEY,
comment text
);
INSERT INTO MixedCase (value, comment) VALUES
('user', 'Ordinary users'),
('moderator', 'Users with the privilege to ban users'),
('administrator', 'Users with the privilege to set users’ roles'); GraphQL query via Hasura console {
MixedCase {
comment
value
}
} Expected response {
"data": {
"MixedCase": [
{
"comment": "Ordinary users",
"value": "user"
},
{
"comment": "Users with the privilege to ban users",
"value": "moderator"
},
{
"comment": "Users with the privilege to set users’ roles",
"value": "administrator"
}
]
}
} Actual response {
"errors": [
{
"extensions": {
"path": "$.selectionSet.MixedCase",
"code": "validation-failed"
},
"message": "field \"MixedCase\" not found in type: 'query_root'"
}
]
} |
When executing your queries you will want to use double quotes (and you might as well add a mixed case column while you are at it) Also be sure to add an Enum type, since that is where the bug is. (Deleted prior comment and amended it for this) ex. CREATE TYPE "MixedCaseType" AS ENUM ('ONE', 'TWO');
CREATE TABLE "MixedCase" (
value text PRIMARY KEY,
"comment" text,
"mixedCaseType" "MixedCaseType"
);
INSERT INTO "MixedCase" (value, "comment", "mixedCaseType") VALUES
('user', 'Ordinary users', 'ONE'),
('moderator', 'Users with the privilege to ban users', 'ONE'),
('administrator', 'Users with the privilege to set users’ roles', 'TWO'); |
This is great, thanks for clarifying @gentleShark ! |
Additional context: We don't generate GraphQL enum types out of Postgres enums instead we generate simple custom scalar type. We treat them as |
Hi @gentleShark , thank you for the detailed bug report, and for your patience whilst we fix it. I'm happy to say this has been fixed at d561024, and will be available in the next stable release within two weeks. |
I have an existing postgres DB with an enum (native Postgres enum type) named "enum_Motivations_desired_solution" on a table named "Motivations". When I try to insert into the table, Hasura throws an error indicating it is looking for an enum of the same name but in lower case. If I re-name the enum in Postgres to be lower case, it solves the problem.
The error:
{
"errors": [
{
"extensions": {
"path": "$.selectionSet.insert_Interactions.args.objects[0].Motivations.data",
"code": "constraint-error"
},
"message": "type "enum_motivations_desired_solution" does not exist"
}
]
}
The query:
The text was updated successfully, but these errors were encountered: