Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Deep update should not be possible if mandatory fields are not present in the input #8781

Open
benwoodward opened this issue Apr 4, 2023 · 3 comments
Labels
area/graphql Issues related to GraphQL support on Dgraph. community Issue or PR created by the community. kind/bug Something is broken. status/accepted We accept to investigate/work on it.

Comments

@benwoodward
Copy link

benwoodward commented Apr 4, 2023

What version of Dgraph are you using?

v22.0.2

Tell us a little more about your go-environment?

I'm using the standalone docker image

Have you tried reproducing the issue with the latest release?

Yes

What is the hardware spec (RAM, CPU, OS)?

not relevant

What steps will reproduce the bug?

schema:

type Project {
  id: ID!
  members: [Member!]
}

type Member {
  id: ID!
  nickname: String!
  favoriteColor: String!
  project: Project! @hasInverse(field: members)
}

Perform deep (nested) update:

mutation UpdateProject($input: UpdateProjectInput!) {
  updateProject(input: $input) {
    project {
      id
      members {
        id
      }
    }
  }
}
{
  "input": {
    "filter": {
      "id": [
        "0x42074"
      ]
    },
    "set": {
      "members": [
        {
          "favoriteColor": "orangey red" // nickname should be here too as it is a required field
        }
      ]
    }
  }
}

result:

{
  "data": {
    "updateProject": {
      "project": [
        {
          "id": "0x42074",
          "members": [
            {
              "id": "0x325aa2"
            }
          ]
        }
      ]
    }
  },
  "extensions": {
    "touched_uids": 22,
    "tracing": {
      "version": 1,
      "startTime": "2023-04-03T23:52:32.2684963Z",
      "endTime": "2023-04-03T23:52:32.3478531Z",
      "duration": 79356900,
      "execution": {
        "resolvers": [
          {
            "path": [
              "updateProject"
            ],
            "parentType": "Mutation",
            "fieldName": "updateProject",
            "returnType": "UpdateProjectPayload",
            "startOffset": 266200,
            "duration": 79044100,
            "dgraph": [
              {
                "label": "preMutationQuery",
                "startOffset": 0,
                "duration": 0
              },
              {
                "label": "mutation",
                "startOffset": 563900,
                "duration": 28755000
              },
              {
                "label": "query",
                "startOffset": 39370300,
                "duration": 39924500
              }
            ]
          }
        ]
      }
    }
  }
}

Query Members

query QueryMember($filter: MemberFilter) {
  queryMember(filter: $filter) {
    id
    source
  }
}

result:

{
  "errors": [
    {
      "message": "Non-nullable field 'nickname' (type String!) was not present in result from Dgraph.  GraphQL error propagation triggered.",
      "locations": [
        {
          "line": 9,
          "column": 5
        }
      ],
      "path": [
        "queryMember",
        0,
        "source"
      ]
    },
    {
      "message": "Non-nullable field 'nickname' (type String!) was not present in result from Dgraph.  GraphQL error propagation triggered.",
      "locations": [
        {
          "line": 9,
          "column": 5
        }
      ],
      "path": [
        "queryMember",
        1,
        "nickname"
      ]
    }
  ],
  "data": {
    "queryMember": [
      null,
      null
    ]
  },
  "extensions": {
    "touched_uids": 13,
    "tracing": {
      "version": 1,
      "startTime": "2023-04-03T23:58:15.1985333Z",
      "endTime": "2023-04-03T23:58:15.2292826Z",
      "duration": 30749300,
      "execution": {
        "resolvers": [
          {
            "path": [
              "queryMember"
            ],
            "parentType": "Query",
            "fieldName": "queryMember",
            "returnType": "[Member]",
            "startOffset": 647000,
            "duration": 29973700,
            "dgraph": [
              {
                "label": "query",
                "startOffset": 880400,
                "duration": 29730700
              }
            ]
          }
        ]
      }
    }
  }
}

Expected behavior and actual result.

Attempting to create a nested object via a deep update should fail/error if required/mandatory field values are not present in the mutation variables. Without this, it is easy to corrupt the data via user error.

Additional information

No response

@benwoodward benwoodward added the kind/bug Something is broken. label Apr 4, 2023
@MichelDiz MichelDiz added community Issue or PR created by the community. area/graphql Issues related to GraphQL support on Dgraph. labels May 5, 2023
@mangalaman93 mangalaman93 added the status/accepted We accept to investigate/work on it. label May 30, 2023
@mangalaman93
Copy link
Contributor

Thanks for filling the bug. I am able to reproduce it, could you also provide the value of $filter in the query if you still have it?

@benwoodward
Copy link
Author

benwoodward commented May 30, 2023

I am able to reproduce it, could you also provide the value of $filter in the query if you still have

I don't remember, however it was probably just a filter on id, as I tried to keep the example as minimal as possible, e.g.

    "filter": {
      "id": [
        "0x123abc"
      ]
    },

Copy link

This issue has been stale for 60 days and will be closed automatically in 7 days. Comment to keep it open.

@github-actions github-actions bot added the Stale label Jul 21, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 29, 2024
@harshil-goel harshil-goel reopened this Jul 30, 2024
@github-actions github-actions bot removed the Stale label Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/graphql Issues related to GraphQL support on Dgraph. community Issue or PR created by the community. kind/bug Something is broken. status/accepted We accept to investigate/work on it.
Development

No branches or pull requests

4 participants