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

Remove url resolvers as server actions #209

Open
mobeigi opened this issue Oct 27, 2024 · 1 comment
Open

Remove url resolvers as server actions #209

mobeigi opened this issue Oct 27, 2024 · 1 comment
Labels
bug Something isn't working Payload CMS Related to Payload CMS.

Comments

@mobeigi
Copy link
Owner

mobeigi commented Oct 27, 2024

The async url resolvers are current server actions.

This is because the link node type ReactNode resolver relies on these functions for internal links.
The resolvers are server side because they need to fetch a doc to populate doc relationships that might not be there (due to Payload using depth 0 by default).

Finally, CommentSection, a client side component uses serializeLexical which is fully client side except for the link node which is the only async server side resolver.

Some solution ideas:

  • Payload: If Payload allowed us to populate the url field for internal links at edit time. This way the JSON section for links would be properly self-contained (as is the case for external links). This would allow us to keep link node fully client side solving the problem. However, one issue with this approach is the persisted url would need to be invalidated / updated if the url setter function logic changes.
  • Avoid calling serializeLexical in client-side components (currently only CommentSection), make the resolution happen at a higher level and pass it down to client side components. Basically, treat serializeLexical as fully server-side only.
@mobeigi mobeigi added bug Something isn't working Payload CMS Related to Payload CMS. labels Oct 27, 2024
@mobeigi
Copy link
Owner Author

mobeigi commented Oct 27, 2024

Discussion on Payload Discord help thread:
https://discord.com/channels/967097582721572934/1300047914566942741/1300047914566942741

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Payload CMS Related to Payload CMS.
Projects
None yet
Development

No branches or pull requests

1 participant