Commit Graph

61 Commits

Author SHA1 Message Date
Sunli 03f6ed4ba2 Rename InputValueType to InputType and OutputValueType to OutputType. 2020-12-11 15:37:50 +08:00
Koxiaet 9d94c933ff Don't duplicate type names in parsing error message 2020-11-07 06:05:59 +00:00
Sunli 82333e49b9 Remove the validation of the `content-type` by the `receive_batch_body` function, because this is of little significance. #332 2020-11-01 11:31:54 +08:00
Sunli 055936f9ad Derive Serialize for Request and Deserialize for Response. 2020-10-23 08:26:48 +08:00
Koxiaet 2756c2cd5b Require JSON content-type 2020-10-15 18:30:16 +01:00
Sunli 03b276fe7e Fix a small bug. 2020-10-15 16:45:33 +08:00
Koxiaet d34ac0ba08 Make imports consistent 2020-10-15 07:38:10 +01:00
Sunli 10cd868f4c Some improvements. 2020-10-10 16:28:07 +08:00
Aurelien Foucault dff328a85c Add eq for errors 2020-10-08 15:32:37 +02:00
Sunli e47360d1a2 Fix typo. #297 2020-10-04 07:49:56 +08:00
Sunli e263c755e2 Restore the original error extension implementation. 2020-10-02 14:56:10 +08:00
Sunli 1e30712726 Merge branch 'master' into rework-errors 2020-10-01 09:39:47 +08:00
Sunli fd4c2b193b Added Apollo persisted queries extension. #280 2020-09-30 11:37:12 +08:00
Koxiaet 2ddaaaa07f 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 9333583483 Improve the error message of Tracing extension. 2020-09-26 12:35:28 +08:00
Koxiaet 0880be3e0b 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
Koxiaet 3c04411780 Remove code duplication for batch requests 2020-09-17 19:43:03 +01:00
Sunli dc77e7f262 Update docs 2020-09-17 09:03:36 +08:00
Koxiaet f82322045e Document features 2020-09-15 19:32:13 +01:00
Koxiaet a86c3a86b8 Remove and feature-gate dependencies 2020-09-14 19:38:41 +01:00
Sunli 7a90069cad Continue to refactor. 2020-09-10 16:39:43 +08:00
Koxiaet e3e58d261d Rewrite async-graphql-parser 2020-09-06 06:38:31 +01:00
Sunli d04b5b675f Fix the test code and add docs. 2020-09-01 09:10:12 +08:00
Koxiaet 945cd72869 Remove dependency on serde_derive, satisfy Clippy, improve docs 2020-08-31 19:18:02 +01:00
Sunli c7c4de94ed Replace log crate with xlog. 2020-07-15 18:05:24 +08:00
Kevin Schoonover 80ff792f1a Add input validator tests + fix clippy errors 2020-06-01 16:42:13 -05:00
sunli e949cb441c Add defer tests 2020-05-20 13:42:55 +08:00
Sunli 6cda0644c6 Upgrade multer to 1.1.1 2020-05-18 09:32:55 +08:00
sunli 44b1eb4fb4 Replace multipart parser with multer. 2020-05-17 16:26:36 +08:00
sunli 83579077d9 Support Upload Stream #15
I think the previous implementation is not elegant enough, the `QueryBuilder::set_files_holder` function looks disgusting, so I refactored it.
By the way, the performance of parsing InputValue has been optimized, and unnecessary clones have been removed.
2020-05-11 21:47:24 +08:00
sunli 6d7d64866b The error reason can be returned when the input value is parsed incorrectly. #70 2020-05-10 18:27:46 +08:00
sunli da26857379 Move the parser to async-graphql-parser crate. 2020-05-09 22:02:55 +08:00
sunli 311859e12a Merge branch 'parser'
Implement a new GraphQL query parser and remove the dependency on graphql-parser.
2020-05-09 17:55:04 +08:00
sunli 98864c6879 Add field guard 2020-05-02 07:57:34 +08:00
sunli f11d52825b Update error.rs 2020-04-22 19:09:59 +08:00
sunli 6eb6c9cd9a Fix interface resolver bug 2020-04-22 14:59:14 +08:00
sunli db32d2a071 v1.9.5 2020-04-21 12:13:14 +08:00
sunli 26046ce809 v1.9.0 2020-04-14 09:53:17 +08:00
sunli b880a937ce Add GQLHttpRequest and IntoQueryBuilder trait 2020-04-11 17:36:05 +08:00
sunli f1d0b3f641 Add federation support 2020-04-09 22:03:09 +08:00
sunli 9b9e5385cb Update error.rs 2020-04-02 14:40:00 +02:00
sunli b3525356c9 Extract line and column from ParseError 2020-04-02 12:37:04 +08:00
sunli 10105b8a09 Reimplement the error type and remove the dependency on the anyhow::Error 2020-04-02 10:21:04 +08:00
Nicolai Unrein 2b7320d6c6 ExtendedError and ResultExt inital draft 2020-03-29 16:31:45 +02:00
sunli 457e30ea2f v1.5.2 2020-03-25 15:07:16 +08:00
sunli 2b2be34d4d Clippy cleanup 2020-03-21 09:32:13 +08:00
sunli d95c0f23b8 v1.3.2 2020-03-20 11:56:08 +08:00
sunli ac044d6d30 add GraphQL Cursor Connections 2020-03-19 17:20:12 +08:00
sunli e6cfaf134e Support subscription 2020-03-17 17:26:59 +08:00
sunli f78a172241 Add support for multipart request 2020-03-14 11:46:20 +08:00