Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documenting error responses of GraphQL API #11071

Closed
1 task done
laymonage opened this issue Oct 11, 2021 · 2 comments
Closed
1 task done

Documenting error responses of GraphQL API #11071

laymonage opened this issue Oct 11, 2021 · 2 comments
Labels
content This issue or pull request belongs to the Docs Content team

Comments

@laymonage
Copy link
Contributor

laymonage commented Oct 11, 2021

Code of Conduct

What article on docs.github.com is affected?

https://docs.github.com/en/graphql/reference

What part(s) of the article would you like to see updated?

GraphQL API always returns HTTP 200 OK status code in the response, so we have to rely on the response data in order to handle errors. Unfortunately, the GraphQL API documentation does not have any information on the types of possible errors. It's not in the GraphQL API schema as well, so the only way to know would be to stumble upon the error yourself and learn the hard way.

Additional information

As a GitHub App developer, predictable errors are always preferable so that we can handle them gracefully.

It would be great if there's a dedicated section for GraphQL API error responses. It should document at least the following errors:

  • Unauthorized errors (bad credentials). AFAIK this uses exactly the same format as the REST API, i.e.
    {
      "message": "Bad credentials",
      "documentation_url": "https://docs.github.com/graphql"
    }
  • Rate limit errors. Unlike the REST API that uses the following format:
    {
      "message": "API rate limit exceeded for X.X.X.X. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)",
      "documentation_url": "https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting"
    }
    The GraphQL API uses the following format:
    {
      "errors": [
        {
          "type": "RATE_LIMITED",
          "message": "API rate limit exceeded for installation ID 12345678."
        }
      ]
    }
  • GraphQL API schema errors, for example:
    {
      "errors": [
        {
          "path": [
            "query",
            "viewer",
            "repositories",
            "first"
          ],
          "extensions": {
            "code": "argumentLiteralsIncompatible",
            "typeName": "Field",
            "argumentName": "first"
          },
          "locations": [
            {
              "line": 9,
              "column": 5
            }
          ],
          "message": "Argument 'first' on Field 'repositories' has an invalid value (\"hello\").   Expected type 'Int'."
        }
      ]
    }

This is somewhat related to #194.

@laymonage laymonage added the content This issue or pull request belongs to the Docs Content team label Oct 11, 2021
@github-actions github-actions bot added the triage Do not begin working on this issue until triaged by the team label Oct 11, 2021
@ramyaparimi ramyaparimi added waiting for review Issue/PR is waiting for a writer's review and removed triage Do not begin working on this issue until triaged by the team labels Oct 11, 2021
@ramyaparimi
Copy link
Contributor

@laymonage
Thanks so much for opening an issue! I'll triage this for the team to take a look 👀

@ramyaparimi ramyaparimi added graphql Content related to GraphQL graphql-description and removed waiting for review Issue/PR is waiting for a writer's review graphql Content related to GraphQL labels Oct 11, 2021
@docubot
Copy link
Contributor

docubot commented Oct 11, 2021

Thank you for opening this issue! Updates to the REST/GraphQL API description must be made internally. I have copied your issue to an internal issue, so I will close this issue.

@docubot docubot closed this as completed Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content This issue or pull request belongs to the Docs Content team
Projects
None yet
Development

No branches or pull requests

3 participants