Skip to content
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

Server Action: Link to benefits from API Reference #981

Open
jsimonrichard opened this issue Dec 10, 2024 · 4 comments
Open

Server Action: Link to benefits from API Reference #981

jsimonrichard opened this issue Dec 10, 2024 · 4 comments
Labels
planned Features or content that are planned but not yet in progress. solid-router Related to Solid Router solidstart Related to SolidStart

Comments

@jsimonrichard
Copy link

📚 Subject area/topic

/solid-router/concepts/actions.mdx

📋 Page(s) affected (or suggested, for new content)

https://docs.solidjs.com/solid-router/concepts/actions

📋 Description of content that is out-of-date or incorrect

I'm not sure if this qualifies as incorrect, but it was confusing. I was trying to learn about why actions are useful---specifically, why they exist when we already have server functions---but based on this page alone it seems like there's no difference (other than being able to pass it to an action prop instead of onSubmit, and to a newbie like myself this doesn't seem that important).

Only after reading https://docs.solidjs.com/solid-router/reference/data-apis/action and watching a video did I understand that action handles redirects (for single-flight mutations) and invalidating caches (either all caches by default or by passing cache keys).

I don't know what the best change would be (or if there even needs to be one), but I thought I'd at least let you all know where there's friction.

🖥️ Reproduction in StackBlitz (if reporting incorrect content or code samples)

No response

@jsimonrichard jsimonrichard added the pending review Awaiting review by team members. label Dec 10, 2024
@brenelz
Copy link
Collaborator

brenelz commented Dec 16, 2024

@jsimonrichard
Copy link
Author

Yes, that would help.

But longer term, it might be nice to include something on the concepts page to discuss why Solid Router needs to handle mutations. Currently the concepts page says:

When developing applications, it is common to need to communicate new information to the server based on user interactions. Actions are Solid Router’s solution to this problem.

It wasn't clear to me what the "problem" was until I realized that the router handles caching. Otherwise, a server function or fetch would do just fine.

@atilafassina
Copy link
Member

I see. yes, it's covered in benefits of actions

But there isn't a clear connection the 2 entries.
The general idea is that the "Reference" pages are to explain API, so in theory if you're there you already know you want to use that API and what for, the docs will only guide you through the ergonomics of how to take out the best from it.

The "Learn" sections are to walk people through the benefits and treadoffs of different approach. This allow us to explain better API that are used together (for example, we need preload in order to explain how actions create Single-flight mutation through our caching system).

So, long-term, I think a clear connection between the routes and providing callouts where the Learn pages can compliment the Reference pages would be ideal.

Suggested action items for this issue

@atilafassina atilafassina added planned Features or content that are planned but not yet in progress. and removed pending review Awaiting review by team members. labels Dec 20, 2024
@atilafassina atilafassina changed the title [Content]: Newbie issue: point of action not clear Server Action: Link to benefits from API Reference Dec 20, 2024
@atilafassina atilafassina added solid-router Related to Solid Router solidstart Related to SolidStart labels Dec 20, 2024
@devagrawal09
Copy link
Contributor

Just left a comment in #914 about potentially restructuring the data loading section and possibly including mutations.
While a callout to the data api docs is a decent solution, I think there should also be an explanation of how to do fetching and mutation together in the start docs, especially since single flight mutations are very much a start feature. Yes solid-router is also necessary, but it can be implemented with any routing/data library that works in start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
planned Features or content that are planned but not yet in progress. solid-router Related to Solid Router solidstart Related to SolidStart
Projects
None yet
Development

No branches or pull requests

5 participants