Mutation provided in Dgraph GraphQL Tour SCHEMA doesn't work

I’m following tutorial Dgraph GraphQL Tour SCHEMA and when I try the provided mutation below it returns an error (page 7 of tutorial)

mutation {
  updatePerson(input: {
    filter: { xid: { eq: "alice" } }
    remove: { manages: null }
  })
}
{
  "errors": [
    {
      "message": "Field \"updatePerson\" of type \"UpdatePersonPayload\" must have a selection of subfields. Did you mean \"updatePerson { ... }\"?",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ]
    }
  ]
}

But this is what the tutorial provides. If I add some fields to the mutation I then get another error

mutation {
  updatePerson(input: {
    filter: { xid: { eq: "alice" } }
    remove: { manages: null }
  }){
    person {
      xid
      manages {
        xid
      }
    }
  }
}
{
      "message": "mutation updatePerson failed because Dgraph execution failed because Got unsupported type for list: Person.manages",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "updatePerson"
      ]
    }
  ],
  "data": {
    "updatePerson": null
  }
}

If I replace remove: { manages: null } by remove: { manages: [] } it no longer yells at me, but I’m not sure it does what it’s supposed to do, meaning remove all edges

It’s not possible to do it the way you’re doing it. If you found this in any tutorial or documentation please point it out to me so I can fix it.

GraphQL is a hard typed language. Everything has to be described explicitly. To delete something you need to point to what you want to delete. That is, you have to pass a list of XIDs to perform the deletion. There is no “delete all * *” in GraphQL. It could be done, but it is a separate and more complex engineering. Which is not part of the GraphQL specification.

This is what the tutorial says. @MichelDiz I can’t see how I could have been more explicit than when I said :point_down: I even gave the page number on the tutorial :grimacing:

I’m following tutorial Dgraph GraphQL Tour SCHEMA and when I try 
the provided mutation below it returns an error (page 7 of tutorial)

Well, maybe this was something added in 21.12 and 21.12 was reverted to 21.03 dut to some issues.

They probably added support for this delete operation, but it has been rolled back. If it really happened you’ll see it back in a few months.

The correct mutation would be

mutation a1{
  updatePerson(input: {
    filter: { xid: { eq: "alice" } }
    remove:  { manages: [ {
          xid: "frank"
        },
        {
          xid: "karl"
        }] }
  }) {
    person {
      xid
      manages {
        xid
      }
    }
  }
}

Then it means that you can’t remove edges without knowing to which node those edges are connected to if I understand correctly Deleting Data | Graphqlschema | Dgraph Tour. It doesn’t make much sense to me …

I believe you skipped over some parts of what I said. But, The GraphQL Tour was created by a third party, a contractor. They may have made a mistake and the reviewer didn’t catch that part. Or, as I mentioned above, there was support for that method but we had a regression. Try downloading version 21.12 and see if it works. If it does, then my theory is correct.

I believe you skipped over some parts of what I said.

I don’t think I did, I’m using the Tour tutorial so I can’t really choose which version to choose. But I’ll try locally with the version you gave me.

But, The GraphQL Tour was created by a third party, a contractor

I don’t think you’ve told me that before but okay

They may have made a mistake and the reviewer didn’t catch that part. Or, as I mentioned above, there was support for that method but we had a regression. Try downloading version 21.12 and see if it works. If it does, then my theory is correct.

Will do, thanks

That was not a mistake at the time, it was a change undocumented by the developers. Yes, I am sure because I wrote that GraphQL and tested it throughly.

You use to be able to do this, but changed in I think 21.03 maybe?

Bug was reported here: Removing edges using null does not work - #3 by amaster507

(it was labeled “ticket created”, so you might want to look into that, even though they’re was never a formal Dgraph response)

And to confirm again, a previous core-dev @pawan even stated that this was the intended behaviour, and a user saw this behaviour:

@cscetbon thanks for pointing this discrepancy between the Tour and the current version.
We are actively revamping the Dgraph documentation including the tutorials (as we have tutorials at different places), Doc team will re-test and update the Tour.

@amaster507 so if I understand it’s a bug and is supposed to be fixed in the future, right ?

@Raphael no problem, it seems I wasn’t the first one to raise this issue as pointed out by @amaster507 see Removing edges using null does not work - #3 by amaster507

1 Like

Fixed in the future or the bug accepted as a “feature”, TBD…

I would rather see it fixed as the user case is still needed and there is no other way around to do a SP* delete except with DQL now. But we’ll have to wait and see if the bug is fixed or the documentation/tour is changed to accept this bug. Only time will tell.

Someone accepted it as a bug, but I think that was the old team, and that bug status appears to have been lost.

1 Like

Not lost anymore. We will fix that.

2 Likes