Replies: 1 comment
-
Hey, thanks for sharing this use case. I can see how, at a minimum, |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Our application is retrieving information about tenants in buildings, and one type of data are reservations for certain parts of buildings. For the current tenant, we retrieve all reservations, using
Reservation
type for reservation owned by the current tenant, andAnonymousReservation
for reservations owned by other tenants. We use a union for this:The problem arises when returning reservations for multiple tenants are being returned at once. In the subtree for tenant A, we return a reservation owned by tenant B, which should be returned as a
AnonymousReservation
. In the subtree for tenant B that same reservation should be returned as aReservation
, because it's owned by tenant B.However, graphql-ruby caches type resolutions for each object. So if a reservation was once resolved as
Reservation
, it cannot be resolved as another type in the same query anymore. We return same reservations as different Ruby objects, but Active Record implementshash
, so those will get treated as being the same in graphql-ruby's hash, because they have the same record ID.Type resolution is super cheap in our case, so we don't need the cache. Is there a way to skip it?
Beta Was this translation helpful? Give feedback.
All reactions