I have this query, where messageTags
is a joining table for a many to many relation between messages
and tags
messageTagsByMessageId {
__id
edges {
node {
tagId
tagByTagId {
id
name
}
}
}
}
I want to run a deleteTag
mutation, and use Relay's @deleteEdge
to update the connection automatically. The problem is the mutation returns id
, not tagId
or tagByTagId.id
:
I tried to do it out of the box:
mutation TagDeleteMutation($input:DeleteTagInput!, $connections: [ID!]!) {
deleteTag(input: $input) {
tag {
id @deleteEdge(connections: $connections)
}
}
}
I also tried adding to the payload out of the box:
mutation TagDeleteMutation($input:DeleteTagInput!, $connections: [ID!]!) {
deleteTag(input: $input) {
tag {
id @deleteEdge(connections: $connections)
}
messageTag {
tagId @deleteEdge(connections: $connections)
}
}
}
No luck. Now I'm working on the Postgres function which graphile uses to build the mutation API. Something like:
CREATE FUNCTION public.delete_tag(tag_id Int)
RETURNS *
AS $$
DELETE FROM public.tag
WHERE id=tag_id
RETURNING id, user_id, name, category_id, id as tag_id;
$$ LANGUAGE sql VOLATILE STRICT;