Conversation
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
…xtensions Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
BrynCooke
left a comment
There was a problem hiding this comment.
In general looks good, but let's remove to_shouty_snake_case.
garypen
left a comment
There was a problem hiding this comment.
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?
|
@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 <5719034+bnjjj@users.noreply.github.com>
| message: String, | ||
| locations: Vec<Location>, | ||
| path: Option<Path>, | ||
| extension_code: T, |
There was a problem hiding this comment.
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]>)
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.