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
{{ message }}
This repository has been archived by the owner on Jul 8, 2023. It is now read-only.
I'm seeing the above error when running a mutation. It's just this specific case where I see this, most basic mutations work fine. The model setup looks like this:
@gql.django.type(Config)
class ConfigType(relay.Node):
items: List["ItemType"]
@gql.django.type(Item)
class ItemType(relay.Node):
label: auto
children: List["ItemType"]
Mutation: Essentially deletes all the Items and recursively recreates them again with the new values
@gql.django.input_mutation
def update_items(
self,
info: Info,
config_id: gql.relay.GlobalID,
items: Optional[List["ItemType"]],
) -> Config:
try:
config: Config = config_id.resolve_node(info, ensure_type=Config)
config.items.all().delete()
for item in items:
parent = Item(
label=item.label,
config=config,
)
parent.save()
update_items_recurse(
config=config, item=item, parent=parent
)
return cast(
Brand,
brand,
)
except Exception:
raise RuntimeError("Unable to update navigation items")
def update_items_recurse(
config: Config,
item: ItemInputPartial,
parent: Item,
):
children = item.children
if children is gql.UNSET or len(children) == 0:
return
for child in children:
child_node = Item(label=child.label, parent=parent)
child_node.save()
update_items_recurse(
config=config, item=child, parent=child_node
)
I'm utilizing the Relay Store on the frontend to auto-update values on the Config object so I'm returning the full Config object in the mutation and re-querying the items field on the Config object on return of the mutation, but something is going wrong with the re-querying part. Maybe because I delete all objects on the config and re-create them?
const updateMutation = graphql`
mutation ShortcutsCardNavigationItemsUpdateMutation(
$input: UpdateNavigationItemsInput!
) {
updateNavigationItems(input: $input) {
... on ConfigType {
id
items {
label
children {
label
children { ... etc }
}
}
}
}
`;
Hope that makes sense. In the meantime I'm going to try to write a custom resolver for the items field to see if that helps at all.
Update: If this helps, I tested this out instead and I see the same error:
@gql.django.type(Config)
class ConfigType(relay.Node):
@gql.django.field
def items(self) -> List["ItemType"]:
return list(self.items.all())
Am I just doing something wrong in the original setup or is there a bug?
The text was updated successfully, but these errors were encountered:
I'm seeing the above error when running a mutation. It's just this specific case where I see this, most basic mutations work fine. The model setup looks like this:
Mutation: Essentially deletes all the Items and recursively recreates them again with the new values
I'm utilizing the Relay Store on the frontend to auto-update values on the Config object so I'm returning the full Config object in the mutation and re-querying the
items
field on theConfig
object on return of the mutation, but something is going wrong with the re-querying part. Maybe because I delete all objects on the config and re-create them?Hope that makes sense. In the meantime I'm going to try to write a custom resolver for the
items
field to see if that helps at all.Update: If this helps, I tested this out instead and I see the same error:
Am I just doing something wrong in the original setup or is there a bug?
The text was updated successfully, but these errors were encountered: