Commit Graph

464 Commits

Author SHA1 Message Date
Koxiaet
768b666acd Merge master 2020-09-30 18:24:24 +01:00
Koxiaet
50009b66ce Rework errors
This completely overhauls the error system used in async-graphql.
- `Error` has been renamed to `ServerError` and `FieldError` has been
renamed to just `Error`. This is because `FieldError` is by far the most
common error that users will have to use so it makes sense to use the
most obvious error name. Also, the current name didn't make sense as it
was used for things other than field errors, such as the data callback
for websockets.
- `ServerError` has been made completely opaque. Before it was an enum
of all the possible errors, but now it just contains an error message,
the locations, the path and extensions. It is a shame that we lose
information, it makes more sense as _conceptually_ GraphQL does not
provide that information. It also frees us to change the internals of
async-graphql a lot more.
- The path of errors is no longer an opaque JSON value but a regular
type, `Vec<PathSegment>`. The type duplication of `PathSegment` and
`QueryPathSegment` is unfortunate, I plan to work on this in the future.
- Now that `ServerError` is opaque, `RuleError` has been removed from
the public API, making it simpler.
- Additionally `QueryError` has been completely removed. Instead the
error messages are constructed ad-hoc; I took care to never repeat an
error message.
- Instead of constructing field-not-found errors inside the
implementations of field resolvers they now return `Option`s, where a
`None` value is representative of the field not being found.
- As an unfortunate consequence of the last change, self-referential
types based on the output of a subscription resolver can no longer be
created. This does not mean anything for users, but causes lifetime
issues in the implementation of merged objects. I fixed it with a bit of
a hack, but this'll have to be looked into further.
- `InputValueError` now has a generic parameter - it's kind of weird but
it's necessary for ergonomics. It also improves error messages.
- The `ErrorExtensions` trait has been removed. I didn't think the
`extend` method was necessary since `From` impls exist. But the
ergonomics are still there with a new trait `ExtendError`, which
is implemented for both errors and results.
- `Response` now supports serializing multiple errors. This allows for
nice things like having multiple validation errors not be awkwardly
shoved into a single error.
- When an error occurs in execution, data is sent as `null`. This is
slightly more compliant with the spec but the algorithm described in
<https://spec.graphql.org/June2018/#sec-Errors-and-Non-Nullability> has
yet to be implemented.
2020-09-29 20:06:44 +01:00
Sunli
4e7bb1a59c Added context for Extension. 2020-09-29 20:47:37 +08:00
Sunli
e60864a18d Rework async-graphql-derive. #288 2020-09-29 16:06:10 +08:00
Sunli
ded45bcf6b Update docs 2020-09-28 11:15:37 +08:00
Sunli
5d315ec6d2 Clippy clean. 2020-09-27 19:29:23 +08:00
Sunli
4d019f1d6f Update schema.rs 2020-09-27 19:13:12 +08:00
Sunli
012e5ee315 Fixed variables cannot deserialize from null. #282 2020-09-27 19:10:49 +08:00
Sunli
fae50062e0 Fix the problem when generating Federation SDL. #283 2020-09-27 18:49:04 +08:00
Sunli
f9cfc14e45 Update docs 2020-09-27 18:22:01 +08:00
Sunli
0d6771a199 Add some type detection to make the defined schema conform to the GraphQL specification. #282 2020-09-27 15:35:05 +08:00
Sunli
7d3eb9b62c Make Object and Subscription macros support #cfg(...) attribute. #281 2020-09-27 10:20:20 +08:00
Sunli
b47d08c5b5 Invoke extensions for execute_schema. 2020-09-26 15:52:59 +08:00
Sunli
5c293ffdc2 Improve the error message of Tracing extension. 2020-09-26 12:35:28 +08:00
Sunli
44a1869112 Update readme 2020-09-26 11:25:21 +08:00
Sunli
c350d182ce When an error occurs in the query, the Tracing extension can output the error message. 2020-09-26 09:49:46 +08:00
Sunli
089e830d26 Add StringNumber type. 2020-09-26 09:22:54 +08:00
Sunli
3e19b23178 Remove unnecessary features for tide and warp integrations. 2020-09-26 08:35:17 +08:00
Koxiaet
aae4c29dd0 Reduce code duplication in batches in actix web 2020-09-25 17:38:12 +01:00
Sunli
5eef10a1c4 Make uuid to optional dependent. 2020-09-25 15:40:04 +08:00
Sunli
b316c30416 Add data_XXX methods to ResolveInfo and remove context field from ResolveInfo. #260 2020-09-25 15:26:29 +08:00
Sunli
8a82954f0b Improve tracing 2020-09-25 15:01:55 +08:00
Sunli
390aac5ddd Merge pull request #275 from simplificAR/export_description
Export description with `Registry::export_sdl`
2020-09-24 09:21:47 +08:00
Koxiaet
9e98d79c88 Rustfmt and write ARCHITECTURE.md 2020-09-23 20:23:15 +01:00
Koxiaet
e97a7d9def Publicize resolver utils and move Scalar there 2020-09-23 19:50:35 +01:00
Koxiaet
70d2dbc39c Big improvements to tide integration 2020-09-23 18:30:03 +01:00
Daniel Wiesenberg
eeb38b69cf Run Rustfmt and Clippy 2020-09-23 15:54:33 +02:00
Daniel Wiesenberg
125eb74fbc Export description with Registry::export_sdl 2020-09-23 15:47:04 +02:00
Sunli
312b8f13d8 Add Schema::sdl method. #191 2020-09-23 14:14:22 +08:00
Koxiaet
6947d95030 Merge branch 'master' of github.com-koxiaet:async-graphql/async-graphql into master 2020-09-22 20:03:33 +01:00
Koxiaet
49462cf05f Move some validations to parser
This commit moves the single anonymous and duplicated operation name
validation rules into the parser, allowing for a nicer format to be
exposed by it. It also adds better error messages to the parser.
2020-09-22 19:59:48 +01:00
Sunli
47329b9458 Add Request::extension method. #271 2020-09-21 15:53:07 +08:00
Sunli
7eb2143b2c Implement Serialize/Deserialize for MaybeUndefine<T>. 2020-09-21 15:22:45 +08:00
Sunli
e12ae8b236 Add BatchRequest support for actixweb and warp integrations. 2020-09-21 14:57:33 +08:00
Sunli
92c5db674a Merge pull request #272 from mwilliammyers/feat/maybe-undefined
Remove Deserialize impl from MaybeUndefined
2020-09-21 07:56:47 +08:00
William Myers
b1763de1ea Remove Deserialize impl from MaybeUndefined
Change Serialize implementation to use the `untagged` attribute.
This handles the common case of directly serializing `MaybeUndefined`,
but deserializing into an `Option<T>`. We could add a more sophisticated
custom deserialize implementation later.
2020-09-20 13:22:51 -07:00
Sunli
22420ee7ec Make ObjectType is public. 2020-09-20 15:47:17 +08:00
Sunli
679385b5de Fix docs 2020-09-20 13:34:49 +08:00
Sunli
1f009c6e57 Merge branch 'master' of https://github.com/async-graphql/async-graphql 2020-09-20 13:28:25 +08:00
Sunli
20d240df47 Fix enum strings in query variables are not converted to proper enums. #270 2020-09-20 13:28:18 +08:00
William Myers
c117cc0bf5 Add more trait implementations to MaybeUndefined
Closes #267
2020-09-19 14:10:54 -07:00
Koxiaet
6095383019 Warp: Replace BoxedFilter with impl Filter 2020-09-19 18:10:46 +01:00
Koxiaet
d2489eca0b Reexport async-graphql-parser 2020-09-19 06:14:59 +01:00
Sunli
73333035bd Fix compiling without features 2020-09-18 15:14:40 +08:00
Sunli
c1d4dbed87 2.0.0-alpha.12 2020-09-18 15:05:07 +08:00
Sunli
45dc3d6d09 Add Upload::into_async_read with blocking 2020-09-18 14:32:00 +08:00
Sunli
e645e9d999 Remove the GQL prefix of all macros. #208 2020-09-18 09:10:24 +08:00
Koxiaet
07d2204773 Remove code duplication for batch requests 2020-09-17 19:43:03 +01:00
Koxiaet
d52268523f Merge branch 'master' of github.com-koxiaet:async-graphql/async-graphql into master 2020-09-17 19:23:15 +01:00
Koxiaet
890b282dd9 Improve websockets 2020-09-17 19:22:54 +01:00