GitHub API V4 - error returns 200 status_code

Should return 400 or 422

response.status_code - 200
response - {
    "errors": [
        {
            "path": [
                "query",
                "organization",
                "repositories",
                "nodes",
                "... repoQuery"
            ],
            "extensions": {
                "code": "useAndDefineFragment",
                "fragmentName": "repoQuery"
            },
            "locations": [
                {
                    "line": 11,
                    "column": 25
                }
            ],
            "message": "Fragment repoQuery was used, but not defined"
        }
    ]
}
1 Like

The GraphQL spec doesn’t make any mention of HTTP status codes in the case of an error. Additionally, I would suggest that the error you show in your post is an application level error, not an HTTP protocol level error. It’s the same thing as when someone submits a value to an HTML form field that is incorrectly formatted … such as an invalid email address. Your web application returns a 200 HTTP status code because everything is fine at the HTTP protocol level, but displays an error message to the user asking them to supply a valid email address in the form.

I hope that helps!

1 Like