validate string input if it's a valid enum #308
Unanswered
khurram-ansari
asked this question in
Q&A
Replies: 1 comment
-
Depends on what you mean by validation. Validation itself in GraphQL is not done on the client-side but the server-side and So, if you have an arbitrary string, then you can either only cast it to the GraphQL enum type, send it as part of your mutation, and let your API validate it, or write code that validates it on the client-side |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a countriesEnum in my schema and I am using graphql.env.ts file.
export type TCountries = ReturnType<typeof graphql.scalar<'CountriesEnum'>>;
I want to validate a string input against it.
I came across the example in docs regarding enums validation using the
scalar
function but I am unable to understand, is this what I should use to achieve the validation?Beta Was this translation helpful? Give feedback.
All reactions