You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into an interesting bug that is caused by how we calculate the unique key in a NestedFilterableConnectionField:
# Unique dataloader key for context.
data_loader_key = tuple((p for p in info.path if isinstance(p, str)))
The bug occurs when there is a polymorphic field that is represented by a Union and a NestedFilterableConnectionField is queried off of the different Union types. The dataloader_key will not be unique even if the root is a different type
Example Setup (Simplified version but hopefully one can fill in the gaps):
query { records { edges {
node {
__typename
... on Video {
id
title
references { edges { node { id } } }
}
... on Image {
id
name
references { edges { node { id } } }
}
}
} } }
When using this setup, the data_loader_key for both Image and Video references is 'records', 'edges', 'node', 'references' even though the ModelLoader's parent_model needs to be different (a reference attached to a Video cannot be found when the parent_model is an Image)
I fixed this by simply adding the class name to the unique key, so different parent classes have different data loaders:
Not sure if it's worth fixing or if there's a better way to do it, but documenting this just in case someone else somehow runs into this particular edge case.
The text was updated successfully, but these errors were encountered:
I ran into an interesting bug that is caused by how we calculate the unique key in a
NestedFilterableConnectionField
:The bug occurs when there is a polymorphic field that is represented by a Union and a
NestedFilterableConnectionField
is queried off of the different Union types. The dataloader_key will not be unique even if the root is a different typeExample Setup (Simplified version but hopefully one can fill in the gaps):
Union classes:
Sample query:
When using this setup, the
data_loader_key
for both Image and Video references is'records', 'edges', 'node', 'references'
even though theModelLoader
'sparent_model
needs to be different (a reference attached to a Video cannot be found when theparent_model
is an Image)I fixed this by simply adding the class name to the unique key, so different parent classes have different data loaders:
Not sure if it's worth fixing or if there's a better way to do it, but documenting this just in case someone else somehow runs into this particular edge case.
The text was updated successfully, but these errors were encountered: