Delete S-P-* method in GraphQL broken for edges to nodes

Report a GraphQL Bug

What edition and version of Dgraph are you using?

Edition:

  • SlashGraphQL
  • Dgraph (community edition/Dgraph Cloud)

BTW @MichelDiz these options ^ don’t make any sense for someone using Dgraph Cloud. What one are we really suppose to select? SlashGraphQL is no more and Dgraph Cloud is not the same thing as the community edition, right?

If you are using the community edition or enterprise edition of Dgraph, please list the version:

Dgraph Version
$ dgraph version
 
PASTE YOUR RESULTS HERE

Have you tried reproducing the issue with the latest release?

Yes, latest I have available on a brand new Cloud spinup.

Steps to reproduce the issue (paste the query/schema if possible)

type Contact {
  id: ID!
  name: String! @id
  category: [Category] @hasInverse(field:"contacts")
}

type Category {
  id: ID!
  name: String! @id
  contacts: [Contact]
}
mutation addData {
  addContact(input: [
    {
      name:"foo",
      category:[
        {name:"a"}
        {name:"b"}
      ]
    },{
      name:"bar",
      category:[
        {name:"a"},
        {name:"c"}
      ]
    }
  ]) {
    contact {
      name
      category {
        name
      }
    }
  }
}
mutation deleteAllCatsFromFoo {
  updateContact(input: {
    filter: {name:{eq:"foo"}}
    remove: {category:null}
  }) {
    contact {
      name
      category {
        name
      }
    }
  }
}

Expected behaviour and actual result.

I expect to delete all categories with results for data.updateContact.contact = [] but instead I still see the categories there.

I have tried:

remove: {category:null}: mutation updateContact failed because Dgraph execution failed because Got unsupported type for list: Contact.category
remove: {category: []}: no error, but not deleted.
remove: {category: [null]}: mutation updateContact failed because Dgraph execution failed because Got unsupported type for list: Contact.category

Also please notice that none of these will throw a type error by any parsing client, but only throws errors on the server. If the S-P-* method is no longer supported by any means on GraphQL then the generated types should be changed to:

input ContactPatch {
  category: [CategoryRef!] # notice the ! inside the list
}

then the errors thrown on the server would also trigger warnings by clients parsing the schema

1 Like

I can’t change this, pinging @dmai

1 Like

FYI I don’t see any test cases for the delete S-P-* method for edges to nodes in github either: dgraph/update_mutation_test.yaml at master · dgraph-io/dgraph · GitHub

It makes sense that there are no test cases if this is not working right. There use to be a way to delete all of an edge to other nodes without knowing the other nodes themselves.

Maybe I’ll try to also tag @anand @Naman ??

@omar If this doesn’t get fixed, then the GraphQL Tour needs to be fixed because it references the ability to delete all edges using the remove: { manages: null } on this page: Deleting Data | Graphqlschema | Dgraph Tour

This is not mentioned in any of the other GraphQL docs though, this use to work because I did complete all of the tour once upon a time and everything was working.

1 Like