Replies: 2 comments 1 reply
-
We will do some changes to the ID serializer to support more custom cases like this. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So this is all about discussion if there should be Tuple serializer inside
IIdSerializer
to make our life with composite keys easier .. :)Currently there are few ways how to work with composite keys but at the end all the solutions are not robust and require custom serializing / reserializing and some workerounds..
If you just need to query data you can build composite key just by
descriptor.AsNode().IdField(t => $"{t.UserID}-{t.ProjectId}") .....
but very soon you will realized that you need to desterilized that if you wanna read that from client by usingINode
interface as example... Than you must parse that separation string after string-type... Another problem comes if you need to read that from query and again we must build ugly workarounds to make it possible...IdSerializer contains another stuff that can add different segments to ID like
_includeSchemaName
based on schema and this can destroy custom workaround around composite keys.. So isn't the best just build Tuple inside IdSerializer ? To prevent this hacks...Currently IdSerializer work with known scalars
int, long ,guid
etc... more:https://github.com/ChilliCream/hotchocolate/blob/ef46423c22a31dc022309c7fc70d83944eb593a4/src/HotChocolate/Core/src/Types/Types/Relay/IdSerializer.cs#L47-L61
So the idea is to extend it to support Tuple<long,long> Tuple<guid,guid>
I think if application scales-up at the end all of users will face to composite keys because we need join objects when we have multiple relations...
Thx for your input... :)
Beta Was this translation helpful? Give feedback.
All reactions