-
Notifications
You must be signed in to change notification settings - Fork 830
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
New top level object: "warnings" #1592
Comments
Thank a lot for your proposal! To be honest I'm skeptical about it. But let me share some thoughts how it could be implemented using an extension in v1.1 anyways. An extension can define additional members of the top-level document:
The name of a member defined by an extension must be prefixes with a namespace:
That means it could not just be Maybe it would be good to extend scope a little bit and support other debug information like
In most cases APIs are meant to be consumed by computer programs. Not sure if API response is the best way to communicate with the developers who are developing clients consuming them. In my experience developers inspect the API response only if changing how client consumes that API or if debuging an issue, which might be related to an API response. So I wouldn't expect that such a warning is noticed by a developer at all. Additionally it comes with a noticable trade-off of increased payload size. Avoiding to send data, which is not needed, over the wire (over-fetching), is one of the most hyped features of GraphQL. |
I think about adding some {
"errors":[
{
"title": "This is a warning",
"detail": "We are testing a warning error type.",
"level": "warning"
},
{
"title": "This is a debug thing",
"detail": "We are testing a debug error type.",
"level": "debug"
}
]
} |
I agree with @jelhan that API responses are not necessarily the best way to communicate with developers, but that only pertains to the "deprecated" use case. All of the other use cases mentioned by @mattholden can be handled by the client to inform the end user. Another use case is where there is a non-fatal error that prevents the API from returning some data (perhaps where a downstream service is unavailable), but the API can still return meaningful and useful data to the client. In this scenario the client needs to know that some data may be missing. In my opinion, it would be extremely useful to either have a top-level |
So.... pitching in here as I've got an interest in this one also :-) Ideally the "errors" structure would be expanded into a "messages" structure of which "errors" is but one, but in the meantime going down the extension route seems the most common sense approach, use that to fine tune it into a workable solution then propose it get adopted into the main spec at some point. |
Situation one:
Situation two:
Situation three:
|
I see it as unlikely that support to the base specification is added before having experience with solutions implemented as extensions. I recommend focusing on achieving what you need in one or more extensions for the time being. |
On Fri, Sep 1, 2023, 06:34 Ben ***@***.***> wrote:
Situation two:
- Start allowing errors next to data in the top object.
- Add a level attribute to each error object. Omitting this attribute
would default to some defined level, likely error.
This seems unreasonable given the compatibility promises. An existing
client might not be able to tolerate responses that combined data and
errors, because detecting errors could, reasonably, cause days to be
ignored and the entire response is handled badly. Many developers would
quickly be confused by getting errors back with successful response codes.
Using a new warnings member that's allowed with either data or errors seems
best.
-Fred
… |
That is understandable, thank you @jelhan. If we create an extension, is there a way of putting it forward for inclusion on the jsonapi.org website? Is anyone on this thread interested in collaborating to create an extension? If so, then perhaps we should move this discussion to https://discuss.jsonapi.org/ (I believe that is the correct place for discussions about extensions) |
Presently, the spec allows for a top level item of 'data' or 'errors' but not both. Therefore, unless you cram something nonstandard into the meta object, there is no way to provide feedback to the user/developer that the request was executed, but with warnings.
Example use cases for warnings include:
All of these are valuable for the developer to know, but JSON:API doesn't give us anywhere official to put them.
Under this proposal, API developers MAY return a top-level 'warnings' key in responses (there is no reason to submit POST data with a warning.) It would be permitted regardless of whether 'data' or 'errors' is present. The 'warnings' key, if present, MUST be an array containing one or more Warning Objects.
A Warning Object should have the same schema as an Error Object, less the 'status' key.
The text was updated successfully, but these errors were encountered: