Skip to content

GraphQL : Unable to filter by id or get a single row #2308

@alchy58

Description

@alchy58

Hi,

I'm trying GraphQL with success to replace REST calls inside a react-native app.
It seem's to reduce loading time a lot.

I have a critical problem
With REST, I can request a user by id or filter the collection by id. Not with GraphQL. It seems to be two differents problems.
Maybe it's somehow related to #2190. In that case, is this possible to backport the patch on the 2.2 branch ?

First problem : unable to get a single row by id
Using GraphQL, I obtain 400 HTTP response with incorrect route error I'm unable to get a stacktrace, nothing in var/log neither than nginx nor php logs. How can I find the stacktrace ?

REST query

curl -X GET "https://my.endpoint.com/users/1" -H  "accept: application/json"

Response

{
  "id": 1,
}

GraphQL query

{
  user(id:1) {
    id
  }
}

Response

{
  "errors": [
    {
      "debugMessage": "No route matches \"1\".",
      "message": "Internal server error",
      "category": "internal",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "user"
      ]
    }
  ],
  "data": {
    "user": null
  }
}

The second problem is on the filter side, it's functionnal on REST but not with GraphQL : I'm getting all the collection

REST query

curl -X GET "https://my.endpoint.com/users?id=1" -H  "accept: application/json"

Response

[
  {
    "id": 1,
  }
]

GraphQL query

{
  users(id:1) {
    edges {
      node {
        id
      }
    }
  }
}

Response

{
  "data": {
    "users": {
      "edges": [
        {
          "node": {
            "id": "/users/1"
          }
        },
        {
          "node": {
            "id": "/users/2"
          }
        },
        {
          "node": {
            "id": "/users/3"
          }
        },
        etc.
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions