Consider changing from juniper::ID to uuid::Uuid #14

Open
opened 2021-12-12 14:25:06 +01:00 by EliasSchriefer · 0 comments

This would technically reduce some of our code, if we used the hyphenated form of UUIDs.

But here's the problem:

Almost all (de)serializations are to/from the hyphenated form due to it being the default in Uuid's implementation of Display, but we currently use the simple form i.e. without hyphens.

The original thought behind choosing the simple form of UUIDs was to reduce storage space in the database and bandwidth in the query responses. It's just four hyphens per UUID though. 🤔

Moving to uuid::Uuid means we would have to do one of the following:

  • Convert every UUID from hyphenated to simple form, also manually implementing sqlx's Encode/Decode/Type traits for every struct using Uuid, and juniper's GraphQLScalar if we also want it the same way on the frontend (more code)
  • Using the hyphenated form instead of the simple form everywhere (probably less code, but the storage/bandwidth problem)
  • We don't i.e. converting the Uuids to Simple and then to String and then to ID (same code)

Is it worth it? What are your thoughts?

This _would technically_ reduce some of our code, if we used the hyphenated form of UUIDs. But here's the problem: Almost all (de)serializations are to/from the hyphenated form due to it being the default in `Uuid`'s implementation of `Display`, but we currently use the simple form i.e. without hyphens. The original thought behind choosing the simple form of UUIDs was to reduce storage space in the database and bandwidth in the query responses. It's just four hyphens per UUID though. :thinking: Moving to `uuid::Uuid` means we would have to do one of the following: - Convert every UUID from hyphenated to simple form, also manually implementing sqlx's `Encode`/`Decode`/`Type` traits for every struct using `Uuid`, and juniper's `GraphQLScalar` if we also want it the same way on the frontend (**more code**) - Using the hyphenated form instead of the simple form everywhere (**probably less code**, but the storage/bandwidth problem) - We don't i.e. converting the `Uuid`s to `Simple` and then to `String` and then to `ID` (**same code**) Is it worth it? What are your thoughts?
EliasSchriefer added the
question
label 2021-12-12 14:25:29 +01:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: WDG/noise-server#14
No description provided.