Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

[✨] Custom Class serialization #87

Closed
swwind opened this issue Mar 19, 2023 · 5 comments
Closed

[✨] Custom Class serialization #87

swwind opened this issue Mar 19, 2023 · 5 comments
Labels
[STAGE-2] incomplete implementation Remove this label when implementation is complete [STAGE-2] not fully covered by tests yet Remove this label when tests are verified to cover the implementation [STAGE-2] unresolved discussions left Remove this label when all critical discussions are resolved on the issue [STAGE-3] docs changes not added yet Remove this label when the necessary documentation for the feature / change is added [STAGE-3] missing 2 reviews for RFC PRs Remove this label when at least 2 core team members reviewed and approved the RFC implementation

Comments

@swwind
Copy link

swwind commented Mar 19, 2023

Is your feature request related to a problem?

I'm using MongoDB and every request contains one or more ObjectId class object which can not be serialized.

And I'm lazy to write a bunch of .maps and .toString()s to convert those fields to string manually.

Describe the solution you'd like

Write a bunch of .maps and .toString()s after every request is too terrible for me.

I'm looking for those solutions

  1. Add a serializer to handle this ObjectId in mongodb (or in bson) just like URL and Date. (ideal but a waste for non-mongodb user)
  2. Implement above serializer as a plugin for runtime. (possible?)
  3. Support custom serialization for any class, such as using toString() or qSerialize() function automatically. (however, using toString() converts any class object into string, which requires additional type transform in useLoader() and useAction, etc.)

Describe alternatives you've considered

n/a

Additional context

No response

@mikuhl-dev
Copy link

https://github.com/bluesky-social/atproto has a class object BlobRef that is also not serializable, would love to write a custom serializer instead of bugging the authors to change it.

@guzart
Copy link

guzart commented Nov 26, 2023

Facing a similar challenge with Prisma returning a Decimal object.

Would it be possible to support adding custom serializers via a vite plugin?

@mhevery
Copy link

mhevery commented Dec 10, 2023

Custom serializers is a complex problem, which is why we have been punting it. Perhaps you can send a PR to add the Decimal Object?

@wmertens
Copy link
Member

I think most custom serializers can be avoided by putting methods in the store that on invocation check if the desired object exists and if not, create it with noSerialize before doing their own work.

The technique I describe here can be useful for that.

I don't think Qwik should ship with support for random libraries but maybe the $sync proposal can help with doing actual custom serialization

@gioboa
Copy link
Member

gioboa commented Oct 14, 2024

We moved this issue to qwik-evolution repo to create a RFC discussion for this.
Here is our Qwik RFC process thanks.

@gioboa gioboa transferred this issue from QwikDev/qwik Oct 14, 2024
@github-actions github-actions bot added [STAGE-2] incomplete implementation Remove this label when implementation is complete [STAGE-2] not fully covered by tests yet Remove this label when tests are verified to cover the implementation [STAGE-2] unresolved discussions left Remove this label when all critical discussions are resolved on the issue [STAGE-3] docs changes not added yet Remove this label when the necessary documentation for the feature / change is added [STAGE-3] missing 2 reviews for RFC PRs Remove this label when at least 2 core team members reviewed and approved the RFC implementation labels Oct 14, 2024
@QwikDev QwikDev locked and limited conversation to collaborators Oct 14, 2024
@gioboa gioboa converted this issue into discussion #163 Oct 14, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
[STAGE-2] incomplete implementation Remove this label when implementation is complete [STAGE-2] not fully covered by tests yet Remove this label when tests are verified to cover the implementation [STAGE-2] unresolved discussions left Remove this label when all critical discussions are resolved on the issue [STAGE-3] docs changes not added yet Remove this label when the necessary documentation for the feature / change is added [STAGE-3] missing 2 reviews for RFC PRs Remove this label when at least 2 core team members reviewed and approved the RFC implementation
Projects
None yet
Development

No branches or pull requests

6 participants