Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Deleting an object that is present in a union field but failing to remove the reference to it causes the API to error #45

Open
benwoodward opened this issue Apr 20, 2022 · 1 comment
Labels
question Further information is requested

Comments

@benwoodward
Copy link

benwoodward commented Apr 20, 2022

Example:

union TextContainer = Word | Phrase

type Paragraph {
  id: ID!
  textContainers: [TextContainer]
  words: [Word!] @hasInverse(field: paragraph)
  phrases: [Phrase] @hasInverse(field: paragraph)
}

type Word {
  id: ID!
  text: String! @search(by: [regexp])
  paragraph: Paragraph!
  phrase: Phrase
}

type Phrase {
  id: ID!
  paragraph: Paragraph!
  words: [Word!]! @hasInverse(field: phrase)
}

If I run deletePhrase() to delete one of the Phrase objects referenced in the Paragraph.textContainers union list, then the API returns the following:

{
  "errors": [
    {
      "message": "Non-nullable field 'xid' (type String!) was not present in result from Dgraph.  GraphQL error propagation triggered.",
      "locations": [
        {
          "line": 12,
          "column": 9
        }
      ],
      "path": [
        "paginateParagraphsWithPhrases",
        0,
        "textContainers",
        3,
        "xid"
      ]
    }
  ],
"data": {
    "paginateParagraphsWithPhrases": [
      {
        "id": "0x42024",
        "transcript": {
          "id": "0x41f6a"
        },
        "start": 0.15,
        "end": 4.19,
        "textContainers": [
          {
            "__typename": "Word",
            "xid": "06dd22c3-3f52-4c4b-aa10-dc177f65e9ee",
            "text": "I'm"
          },
          {
            "__typename": "Word",
            "xid": "0174abd9-a708-4b6f-8f08-e6ae8f36c427",
            "text": "I"
          },
          {
            "__typename": "Phrase",
            "words": [
              {
                "xid": "b42505e7-0379-49c1-95de-64f0ff95212f",
                "text": "only"
              },
              {
                "xid": "e5941e95-8078-487b-a750-15e426dcfa0c",
                "text": "joking."
              }
            ]
          },
          null
        ]
      },

Notice that there is a null in the textContainers list. Desired behaviour is for deleting the Phrase to remove it from the list, or at the very least for the API to just ignore null references.

EDIT: The problem I have now is that I have no idea how to remove that null reference from the list. So the data is effectively corrupted as a result of this simple operation.

This is a problem I'm experiencing in 20.03, I'm assuming it's still an issue in Outserv.

@manishrjain
Copy link
Contributor

manishrjain commented Apr 20, 2022

Outserv is a full rewrite of GraphQL mutations. So, this might not be an issue in Outserv. Can you try this with Outserv?

@manishrjain manishrjain added the question Further information is requested label Apr 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants