Describe the bug
According to the end of 7.1.2 Errors, non-standard fields should be put under extensions in case of error.
Currently when returning an error, this extension behaves like the counter example and sets code, fields, short_message and vars directly:
{
"data": null,
"errors": [
{
"code": "forbidden",
"fields": [],
"locations": [{ "column": 3, "line": 2 }],
"message": "forbidden",
"path": ["some_path"],
"short_message": "forbidden",
"vars": {}
}
]
}
To Reproduce
Setup a GraphQL server and perform a request which triggers an authentication failure.
Expected behavior
The non-standard fields should be put under an extensions key:
{
"data": null,
"errors": [
{
"locations": [{ "column": 3, "line": 2 }],
"message": "forbidden",
"path": ["some_path"],
"extensions": {
"code": "forbidden",
"fields": [],
"short_message": "forbidden",
"vars": {}
}
}
]
}
To not break backward compatibility while providing support for spec-compliant clients, the fields could be duplicated in the meantime:
{
"data": null,
"errors": [
{
"locations": [{ "column": 3, "line": 2 }],
"message": "forbidden",
"path": ["some_path"],
"code": "forbidden",
"fields": [],
"short_message": "forbidden",
"vars": {}
"extensions": {
"code": "forbidden",
"fields": [],
"short_message": "forbidden",
"vars": {}
}
}
]
}
Additional context
I am querying the GraphQL server with a Go client which discards non-standard keys not put under extensions: https://pkg.go.dev/github.com/vektah/gqlparser/v2@v2.5.17/gqlerror#Error
Describe the bug
According to the end of 7.1.2 Errors, non-standard fields should be put under
extensionsin case of error.Currently when returning an error, this extension behaves like the counter example and sets
code,fields,short_messageandvarsdirectly:{ "data": null, "errors": [ { "code": "forbidden", "fields": [], "locations": [{ "column": 3, "line": 2 }], "message": "forbidden", "path": ["some_path"], "short_message": "forbidden", "vars": {} } ] }To Reproduce
Setup a GraphQL server and perform a request which triggers an authentication failure.
Expected behavior
The non-standard fields should be put under an
extensionskey:{ "data": null, "errors": [ { "locations": [{ "column": 3, "line": 2 }], "message": "forbidden", "path": ["some_path"], "extensions": { "code": "forbidden", "fields": [], "short_message": "forbidden", "vars": {} } } ] }To not break backward compatibility while providing support for spec-compliant clients, the fields could be duplicated in the meantime:
{ "data": null, "errors": [ { "locations": [{ "column": 3, "line": 2 }], "message": "forbidden", "path": ["some_path"], "code": "forbidden", "fields": [], "short_message": "forbidden", "vars": {} "extensions": { "code": "forbidden", "fields": [], "short_message": "forbidden", "vars": {} } } ] }Additional context
I am querying the GraphQL server with a Go client which discards non-standard keys not put under
extensions: https://pkg.go.dev/github.com/vektah/gqlparser/v2@v2.5.17/gqlerror#Error