You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What's the best practice of doing input validation with Ariadne. One of the threads mentions that directive-based validation is an anti-pattern, so I'd like to know what would be the correct way of doing it.
Example:
inputMyInput {
id: ID!notNegativeValue: Int!
}
For example, I know that the ID must be a valid uuid, and the nonNegativeValue is strictly non-negative. With directives, I can annotate both of them with smth like @validUuid, write a custom validation logic, and then it will be validated on any level regardless of how nested the input is. I can imagine one more way to be custom scalars but this would require extra integration on the frontend. Also it's possible to transform the input into pydantic BaseModel, but can be pretty slow.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
What's the best practice of doing input validation with Ariadne. One of the threads mentions that directive-based validation is an anti-pattern, so I'd like to know what would be the correct way of doing it.
Example:
For example, I know that the ID must be a valid uuid, and the
nonNegativeValue
is strictly non-negative. With directives, I can annotate both of them with smth like@validUuid
, write a custom validation logic, and then it will be validated on any level regardless of how nested the input is. I can imagine one more way to be custom scalars but this would require extra integration on the frontend. Also it's possible to transform the input into pydantic BaseModel, but can be pretty slow.Best regards,
Petr
Beta Was this translation helpful? Give feedback.
All reactions