GraphQL-查询返回了多个结果

时间:2020-07-02 11:35:54

标签: graphql laravel-lighthouse

我收到错误消息查询返回了多个结果

type Employee{
    emp_id: Int
    emp_name: String
    manager_id: Int
    job_name: String
}

extend type Query{

# these queries returns the error: "The query returned more than one result."
 Employee(manager_id: Int): Employee @find 
 Employee(manager_id: Int): [Employee] @find

# this query returns all the fields of the DB...
 Employee(manager_id: Int): Employee @all 

}

GraphQL游乐场

{
 Employee(manager_id: 66928 ){
   emp_id
   emp_name
   job_name
 }
}


********RESPONSE*******

{
  "errors": [
    {
      "message": "The query returned more than one result.",
      "extensions": {
        "category": "graphql"
      },

这是我的桌子https://www.w3resource.com/sql-exercises/employee-database-exercise/index.php

1 个答案:

答案 0 :(得分:0)

好,我找到了解决方法

type Query {
 Employee(manager_id: Int @where(operator: "=")): [Employee!]! @all 
}

它返回我想要的:D