"unknown field" error is not descriptive enough

How can I make Dgraph give me a more descriptive error?

1 Like

In order to provide the most accurate assistance, I’ll need a bit more context. Could you please elaborate on what exactly you’re trying to do? Where and how are you encountering the error? Which program gave you this error? The more details you provide, the better I can help you troubleshoot and understand the issue at hand.

@MichelDiz Thanks for the response. I am just trying to do a simple mutation using a tool that I wrote. I am pretty sure that the problem is in my tool, and not in my dgraph’s schema. However, it is impossible for me to debug this problem, since dgraph’s error messages are not descriptive.

unknown field. What field exactly?

1 Like

@MichelDiz I tried to gather some debugging logs. So here is my schema:

type Image  {
	id: ID!
	name: String! @id @search(by:[exact])
	namespace: String
	imageStreamRef: String
	parents: [Image] @hasInverse(field:children)
	children: [Image] @hasInverse(field:parents)
	fromRoot: Boolean
	source: String
}

Here is the call that the client is doing:

{
  "query": "mutation($input:UpdateImageInput!){updateImage(input: $input){numUids}}",
  "variables": {
    "input": {
      "filter": {
        "name": {
          "eq": "openshift/ansible-runner:latest"
        }
      },
      "set": {
        "fromRoot": false,
        "imageStreamRef": "ansible-runner",
        "name": "openshift/ansible-runner:latest",
        "namespace": "openshift",
        "source": "docker.io/ansible/ansible-runner:latest"
      }
    }
  }
}

Error: unknown field. Is there any way to configure Dgraph to log more descriptive error messages? I am not sure what field is wrong here.

1 Like

Which endpoint are you sending this?

To the /graphql endpoint.

I see. I’ve tested your Schema, and the problem seems to hinge on one particular point. You’re attempting to update a string that’s been defined as an ID. When you do this, it’s not possible to update it. I agree that the error message you’re getting isn’t very helpful. However, if you were using a GraphQL IDE, you’d be able to see the error displayed in the Query Variables field.

In Insomnia, it flags the key “name”: “openshift/ansible-runner:latest” with the error

Type “ImagePatch” does not have a field “name”.

The reason for this is that you can’t change a field that’s been defined as an ID, as IDs are unique. In your case, “openshift/ansible-runner:latest” doesn’t seem like an ideal pattern for defining IDs… you might want to choose another pattern.

By the way, you can create new objects by specifying their name (which MUST be unique since you’re using it as an ID), but you can’t use updateImage for this purpose.

1 Like