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

Replace superjson with a generated serialization layer #2027

Open
sodic opened this issue May 10, 2024 · 0 comments
Open

Replace superjson with a generated serialization layer #2027

sodic opened this issue May 10, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@sodic
Copy link
Contributor

sodic commented May 10, 2024

Wasp has used superjson for serializing RPC payloads since #1090.

Superjson is great, but it makes the JSON payloads less user-friendly (which isn't a big deal most of the time but becomes pretty annoying when you start writing API tests).

For example, instead of:

{
  "dob": "2024-05-10T09:44:35.883Z",
  "name": "King Koopa"
}

The payload becomes:

{
  "json": {
    "dob": "2024-05-10T09:44:35.883Z",
    "name": "King Koopa"
  },
  "meta": {
    "values": {
      "dob": [
        "Date"
      ]
    }
  }
}

The included metadata is necessary for the client to properly (de)serialize the payload (which was the whole point of including superjson :)).

However, since Wasp generates the code for both the client and the server, there's no need to transfer the metadata over the wire - we can generate the serialization layer on both the server and the client (e.g., with Zod).

This will simplify our payloads, thus making the API easier to test using different HTTP clients (curl, Postman, etc.).

When designing the new serialization layer, consider the points outlined in #143 (comment) and #1070.

@sodic sodic added the enhancement New feature or request label May 10, 2024
@sodic sodic changed the title Consider replacing superjson with a generated serialization layer Replace superjson with a generated serialization layer May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant