strawberry-django icon indicating copy to clipboard operation
strawberry-django copied to clipboard

Feature request: Support for Django form validation

Open holtergram opened this issue 3 years ago • 3 comments

Hey, is there any possibility to add some support for the Django form validation by also returning the field parameters via GraphQL? What I was thinking of is something like this which takes whatever is defined in the model and passes it to the frontend so that I'd be possible to create some auto-validation based on the backend.

User {
  "firstname": {
    "value": "James",
    "validation": {
      "type": "String",
      "max_length": 30
    }
  }
}

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar

holtergram avatar Apr 14 '21 08:04 holtergram

We do not support Django forms yet. That's very interesting idea. One option would be to provide validation information as a separate object.

We are currently designing the API and stablizing it but Django forms are definitely something we want to think about seriously in the near future.

Thanks for your feedback!

la4de avatar Apr 14 '21 15:04 la4de

Correct me if I'm wrong, but this has little to do with Django Forms? I think what you are looking for is adding meta information to a type that includes a validation schema. I think this would be based on models, not on forms?

joeydebreuk avatar Apr 18 '21 08:04 joeydebreuk

Correct me if I'm wrong, but this has little to do with Django Forms? I think what you are looking for is adding meta information to a type that includes a validation schema. I think this would be based on models, not on forms?

Yes, you're right. I should've been more clear. What I mean is to expose the model parameters / meta information to the frontend. On top of this I think a CSRF token validation would come in handy.

holtergram avatar Apr 18 '21 08:04 holtergram