-
Notifications
You must be signed in to change notification settings - Fork 61
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
Research: Submit forms through GraphQL query #10
Comments
I've begun this work and have been evaluating possible solutions to this problem. After discussing and interviewing Ingo I’ve based on research given these assumptions
Those are two large assumptions but for now those are holding true. Points 1 - 4 in the above would only be an issue if we dropped those 2 assumptions and moved all form submission handling to GraphQL which is clever but would potentially lose a significant benefit of SilverStripe. Anyho, Approach 1. FormMutationInitially, I tested a PoC using a standard Currently Forms are built and accessed via controllers (i.e /admin/assets/EditForm/5) and submitting to the URL submits for correct form however, via graphql mutation we lose that routing so we need to be able to initialise the same Form object given some context from the mutation POST. In my PoC the As this approach would require moving permission checking and other logic from controllers to form objects it's deemed too major for 4.0 but likely for 5.0 for CMS forms as it would enforce practises through strict typing such as standard form return types. I’m not sure it provides any major benefit overall (apart from reducing boilerplate) but introduces complexity behind the scenes. Though, it would allow Form level rules and validation while using strict typing. Approach 2. Generate GQL direct to modelDitch Not considered in depth as it would void assumption 2 and result in a significant shift. Approach 3. As-is++This approach keeps form submissions exactly how they are and simply adds some functionality to form schema in the way of passing back a list of object keys, fields and values that have changed. This approach is the preferred for 4.0 as individual forms can opt-in to this API end point. The list of fields modified would be automatically populated based on calls to Alternatively we could simply track object Id's that have been modified and do a second graphql query on form response. It's another HTTP round trip but would require less specific change tracking. TODO
References |
I've created a separate issue for sorting out the PHP form API required to implement Approach A: silverstripe/silverstripe-framework#6334 |
Research closed in favour of Approach A, with client-side work defined in Submit forms through GraphQL, and more work defined in Update GraphQL models after form submission |
…-deps Update build dependencies
…-2019-19325 [CVE-2019-19325] XSS through non-scalar FormField attributes
This is a subset of the issue DataObject subclass/extension in queries and mutation. At the moment we're using form schema to construct forms in React, but are submitting them via a standard url encoded POST request. This conceptually overlaps with GraphQL mutations and types.
Issues:
CMSMain
orModelAdmin
.The text was updated successfully, but these errors were encountered: