Skip to content

Feature request: allow full customization of URL search params and body serialization #1389

@jedwards1211

Description

@jedwards1211

Describe the feature

I want to use devalue instead of superjson; devalue only provides a stringify method, not one that produces the transformed pre-stringified JSON.

I can work around this by wrapping the serialized string in an object, but that's a waste of bytes. Or I can just return a string anyway and suppress type errors, it does work but in either case the response body is an ugly quoted string. Or I could serialize to JSON.parse(devalue.stringify(data)) but that's a waste of CPU... apparently devalue.stringify builds the string directly for performance's sake so I'm not sure they're going to provide a serialize-to-object function.

Looking at the code, I guess this is so that oRPC can handle serializing to URL search params or body?

It would be nice if we have the option to provide separate serializers for URL search params and body so that we have full control of both and aren't faced with unhappy workarounds in a case like this.

Not saying I think the StandardRPCSerializer or StandardRPCLinkCodec interfaces need to be replaced, just that I wish we could extract lower-level interfaces that people can optionally use.

Additional information

  • Would you be willing to help implement this feature?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions