-
Notifications
You must be signed in to change notification settings - Fork 275
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
more consistent errors #2178
more consistent errors #2178
Conversation
Signed-off-by: Benjamin Coenen <[email protected]>
This comment has been minimized.
This comment has been minimized.
…xtensions Signed-off-by: Benjamin Coenen <[email protected]>
Signed-off-by: Benjamin Coenen <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general looks good, but let's remove to_shouty_snake_case
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the look of this PR. I'd like to see some examples of how errors will look before/after. I can see that a bit from the way tests have changed, but it would be nice to see it written out maybe in an issue or at least on the PR.
If we made this change would it effectively be a router 2.0 change? I mean do we think this is part of our public API?
Signed-off-by: Benjamin Coenen <[email protected]>
@garypen I don't think it should be a 2.0 change. Because we didn't really remove something, we just added more context to errors so it's additive |
Signed-off-by: Benjamin Coenen <[email protected]>
Signed-off-by: Benjamin Coenen <[email protected]>
message: String, | ||
locations: Vec<Location>, | ||
path: Option<Path>, | ||
extension_code: T, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new method should be added in the documentation:
/// Returns a builder that builds a GraphQL [`Error`] from its components.
///
/// Builder methods:
///
/// * `.message(impl Into<`[`String`]`>)`
/// Required.
/// Sets [`Error::message`].
///
/// * `.locations(impl Into<`[`Vec`]`<`[`Location`]`>>)`
/// Optional.
/// Sets the entire `Vec` of [`Error::locations`], which defaults to the empty.
///
/// * `.location(impl Into<`[`Location`]`>)`
/// Optional, may be called multiple times.
/// Adds one item at the end of [`Error::locations`].
///
/// * `.path(impl Into<`[`Path`]`>)`
/// Optional.
/// Sets [`Error::path`].
///
/// * `.extensions(impl Into<`[`serde_json_bytes::Map`]`<`[`ByteString`]`, `[`Value`]`>>)`
/// Optional.
/// Sets the entire [`Error::extensions`] map, which defaults to empty.
///
/// * `.extension(impl Into<`[`ByteString`]`>, impl Into<`[`Value`]`>)`
/// Optional, may be called multiple times.
/// Adds one item to the [`Error::extensions`] map.
///
/// * `.build()`
/// Finishes the builder and returns a GraphQL [`Error`].
We need to add .extension_code(impl Into<
[String
]>)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created an issue #2469 Thanks a lot
related to #2101
This is a draft/attempt to have more consistent errors in the router following this spec https://www.apollographql.com/docs/apollo-server/data/errors/ with the error extension code.