-
-
Notifications
You must be signed in to change notification settings - Fork 63
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
Error when getting enum value => Argument 'input' has invalid value #240
Comments
This is by design as enum values are all caps by convention following the recommendations in the GraphQL spec: |
I'm not saying that this is not the convention, But for my case, the enums are already there (i'm mocking a real third party graphql server) and they are PascalCase. It would be really great if you can provide me with a solution to convert the values to PascalCase, i'm out of ideas :( Thanks |
You can use the See the |
hoped for a more generic solution to apply for all enums but this will do. Thanks a lot |
See answer in #241 – adding your own attribute implementing |
So, after trying what you said previously, nothing really worked but i closed the issue because i went with sending the enum as a string and parsing it later (which i really don't like). And now, since I'm back working at this, I tried creating a class implementing the both MetaDataAttributeBase and IDefaultAttribute, to override MapEnumMember, but it seems that it's executed before the MapEnumMember of the NameAttribute. if the NameAttribute class had virtual methods I could override its implementation but that's not the case. Is it a choice you made that only Constant Case enums are supported unless specifying explicitly on each enum member (which is a pain to be honest since we have hundreds of enums). I propose 3 simple solutions :
|
I'm using the conventions library as a mock server, and I couldn't figure out how to map values, here's a query example
`
test(input: {
accountName: "Compte principal"
name: "test"
companyType: Association // this is an enum as you can see not a string value
businessActivity: AdministrativeServices // same
monthlyPaymentVolume: Between10000And50000 // same
email: "[email protected]"
language: "FR"
}
}
`
And i'm using a I'm only using a requestHandler, so when i get a request I pass it to requestHandler.ProcessRequestAsync.
I have a workaround to pass the enum as string value and then parse it, but i'd rather not.
here's the full error I got:
In field 'businessActivity': [Expected type 'BusinessActivity', found AdministrativeServices.] In field 'monthlyPaymentVolume': [Expected type 'MonthlyPaymentVolume', found Between10000And50000.]","locations":[{"line":2,"column":31}],"extensions":{"code":"FIELD_RESOLUTION","codes":["FIELD_RESOLUTION","ARGUMENTS_OF_CORRECT_TYPE_ERROR"]}}]
The text was updated successfully, but these errors were encountered: