Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
434 views
in Technique[技术] by (71.8m points)

java - Error : The non-nullable type is 'ID' in Spring Boot with the usage of Graphql

I just devised an example of Spring Boot with the usage of Graphql.

I tried to update the department by id but I got an error in id part.

Here is my error message which is shown below.

The field at path '/updateDepartment/hospital/id' was declared as a non null type, but the code involved in retrieving data has wrongly returned a null value.  The graphql specification requires that the parent field be set to null, or if that is non nullable that it bubble up null to its parent and so on. The non-nullable type is 'ID' within parent type 'Hospital'

Here are my mutation and query variables snippets which is shown below.

mutation updateDepartment($departmentInput: DepartmentInput!) {
  updateDepartment(id: 10,department: $departmentInput){
    name
    hospital{
      id
    }
  }
}

{
  "departmentInput": {
    "name": "Department 10 Update",
    "hospitalId": 3
  }
}

Here is my project link : Project Link

How can I fix that error?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Here is my solution

Mutation

mutation updateDepartment($departmentInput: DepartmentInput!) {
  updateDepartment(id: 10,department: $departmentInput){
    name
  }
}

Query Variables

{
  "departmentInput": {
    "name": "Department 10 Update",
    "hospitalId": 3
  }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...