未使用别名时出现FieldsConflict类型的graphql验证错误

未使用别名时出现FieldsConflict类型的graphql验证错误,graphql,graphql-java,github-graphql,graphql-spring-boot,Graphql,Graphql Java,Github Graphql,Graphql Spring Boot,当我在请求中未使用别名时,我收到错误“类型FieldsConflict的验证错误”。请确认这是否是预期的,或者是否有解决办法 { person(search: [{firstname: "DAN", lastname: "WATLER", country: "FRANCE"}]) { firstname lastname country age address } pe

当我在请求中未使用别名时,我收到错误“类型FieldsConflict的验证错误”。请确认这是否是预期的,或者是否有解决办法

{
    person(search: [{firstname: "DAN", lastname: "WATLER", country: "FRANCE"}])
    { 
        firstname
        lastname
        country
        age
        address      
    }

    person(search: [{firstname: "FRANK", lastname: "TEE", country: "FRANCE"}])
    { 
        firstname
        lastname
        country
        age
        address      
    }
}
上面的代码给出了验证错误,但若我使用下面显示的别名,错误不会出现,我会得到成功的响应

我不想使用别名,请建议任何解决方法。 谢谢

{
    dan: person(search: [{firstname: "DAN", lastname: "WATLER", country: "FRANCE"}])
    { 
        firstname
        lastname
        country
        age
        address      
    }

    frank: person(search: [{firstname: "FRANK", lastname: "TEE", country: "FRANCE"}])
    { 
        firstname
        lastname
        country
        age
        address      
    }
}

通常,
GraphQL
以JSON对象的形式返回数据,在一个JSON文档中不可能有两个(有效)具有相同密钥的对象(在您的例子中是
person
)。因此,要实现您所描述的目标是非常不可能的

第一次查询的结果如下:

{
  "data": {
    "person": {
      "firstname": "DAN",
      ...
    },
    "person": { // this is not valid
      "firstname": "FRANK"
      ...
    }
  }
}
这就是为什么您必须使用
alias

另一个选项是查看GraphQL服务器是否有一个返回
person
列表的查询,结果是否在数组中,如:

{
  "data": [
    {
      "firstname": "DAN",
      ...
    },
    {
      "firstname": "FRANK",
      ...
    }
  [
}

通常,
GraphQL
以JSON对象的形式返回数据,在一个JSON文档中不可能有两个(有效)具有相同密钥的对象(在您的例子中是
person
)。因此,要实现您所描述的目标是非常不可能的

第一次查询的结果如下:

{
  "data": {
    "person": {
      "firstname": "DAN",
      ...
    },
    "person": { // this is not valid
      "firstname": "FRANK"
      ...
    }
  }
}
这就是为什么您必须使用
alias

另一个选项是查看GraphQL服务器是否有一个返回
person
列表的查询,结果是否在数组中,如:

{
  "data": [
    {
      "firstname": "DAN",
      ...
    },
    {
      "firstname": "FRANK",
      ...
    }
  [
}