GraphQL

Write an awesome doc for GraphQL. A very nice an practical one extracted from GraphQL official documentation.

View on GitHub

Common validation errors

[!TIP]

Requesting non-existent fields

{
  "errors": [
    {
      "message": "Cannot query field 'deadline' on type 'Todo'.",
      "locations": [{ "line": 4, "column": 5 }]
    }
  ]
}

When a query returns an array of objects then you have to specify what you want

Trying to query fields of a scalar or enum doesn’t make sense, Right?

{
  "errors": [
    {
      "message": "Field 'name' must not have a selection since type 'String!' has no subfields.",
      "locations": [{ "line": 4, "column": 10 }]
    }
  ]
}

Missing inline fragments in queries for APIs that return a union

E.g. if you’re searching in audit-log and try { search(tags: ["warn"]) { serialNumber } } query you will get an error like this:

{
  "errors": [
    {
      "message": "Cannot query field 'serialNumber' on type 'EventSource'. Did you mean to use an inline fragment on 'Robot'?",
      "locations": [{ "line": 5, "column": 5 }]
    }
  ]
}

Cannot use a named fragment inside itself

Request errors

Field errors

Network errors