postgraphile-plugin-nested-mutations icon indicating copy to clipboard operation
postgraphile-plugin-nested-mutations copied to clipboard

Table referencing itself

Open francescovenica opened this issue 3 years ago • 4 comments

Hello,

I have a question about a case where a table has a parent_id like this:

CREATE TABLE item (
  uuid uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
  parent_uuid uuid REFERENCES item (uuid) ON DELETE CASCADE,
  title text
);

is it possible from this to create the parent item and also the child item (wo where parent_uuid is the uuid of the parent item)?

many thanks

francescovenica avatar May 02 '21 23:05 francescovenica

Yes it is.

mutation CreateItemMutation {
  createItem(input: {
    item: {
      title: "parent"
      itemsToParentIdUsingId: {
        create: [{
          title: "child A"
        }, {
          title: "child B"
        }]
      }
    }
  }) {
    clientMutationId
  }
}

Eldow avatar Jun 25 '21 09:06 Eldow

@Eldow I know a lot of time passed but I'm still have this issue, I'm not able to create more then 1 child, how did you get that working with an array?

francescovenica avatar Feb 06 '22 23:02 francescovenica

It seems this issue is a duplicate of #33 which is currently not fixed

tmair avatar Dec 12 '22 13:12 tmair

It might be worth checking out my fork : https://github.com/Eldow/postgraphile-plugin-nested-mutations It fixed some of the issues I faced at the time but I ended up stopping using it in the end in favor of custom mutations.

Eldow avatar Dec 13 '22 11:12 Eldow