0

我在 Symfony 4 框架中设置了没有 docker 的 api-platform 并添加了 GraphQL 支持,如此处所述 - https://api-platform.com/docs/core/graphql

使用 GraphiQL 时,我似乎只得到空响应,我尝试了很多不同的 GraphQL 语法,都返回空。

GraphiQL 中的空响应

我试过了:

{
  user{
    id
  }
}

-

{
  user(id: 1){
    id
  }
}

-

{
  users(id: 1){
    id
  }
}

都没有运气

我可以正常请求api并得到响应。

API测试器中的成功请求

此外,GraphiQL 中的请求似乎都已发布,但这可能无关紧要。

我一直在尝试解决此问题一段时间,但未能在网上找到任何帮助。

谢谢

4

1 回答 1

1

好吧,我为那些有同样问题的人找到了答案。

api-platform 使用 uuids,您必须在 graphql 中使用它进行搜索

query {
    user(id: "users/1"){
        firstName
        lastName
    }   
}
于 2018-04-16T21:07:09.353 回答