-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
New Actions type is overly restrictive #6015
Comments
This is meant as a short-term fix until whenever the result of #5875 lands. Ideally that solution also accommodates this use case. |
* [fix] make errors in Action less restrictive Part of #6015 * changeset
The types are relaxed. I'm having a hard time figuring out if this is two issues in one. Could you clarify if the things you mentioned are solved? |
The main issue (regression in capability) is fixed. I'm guessing you're looking at the If that's a change the maintainers are interested in pursuing, I'd be happy to open another issue for tracking. Otherwise I can work with a |
Thanks for the answer, closing then. After the form discussion proposal is finalized and implemented, you can revisit this and open an issue if you like. |
Describe the problem
I took a stab at upgrading to SvelteKit post #5748. There's a fundamental regression of capability with the Action type compared to how POST page endpoints worked previously. Before 5748 landed, the returned body of the POST handler would be layered on top of the body of the GET handler. This allowed the POST handler to influence the rendering of the page component by providing additional data.
The Action type allows something similar by returning the
error
value, but it's limited to theRecord<string, string>
type which doesn't allow passing complex data back to the page component.Describe the proposed solution
I'd suggest replacing
error
withform_result
(action_result
?) and loosening the type fromRecord<string, string>
to something likeRecord<string, any>
or the oldJsonValue
.Alternatives considered
Alternative 1: Serialized JSON Hack
Theoretically you could pass serialized json as one of the string values in
error: Record<string, string>
but that obviously feels like a hack counter to the spirit of whaterror
is supposed to represent.Alternative 2: External Data Passing
The developer can externally store the complex data somewhere and manually look it up the next time the page's
load
function is invoked. (Think cookies or memory store). This external storage method adds complexity to the form handling process.Importance
would make my life easier
Additional Information
This "pass data from the POST handler to the page component" functionality is important for how I've implemented the "form-local actions" I described in #5875 (comment)
The text was updated successfully, but these errors were encountered: