Commit Graph

34 Commits

Author SHA1 Message Date
Sunli
88ba75ec70 Rework connection types 2022-04-19 19:18:06 +08:00
Sunli
a4b840a984 Add support for oneof field on object. #766 2022-03-04 21:24:17 +08:00
Sunli
e2c6ead1a3 Add DirectivesUnique rule 2021-11-18 20:14:56 +08:00
Sunli
824356d118 Rework Extension 2021-04-04 14:37:41 +08:00
Sunli
0d76987f40 Add Analyzer extension. 2020-12-18 23:58:03 +08:00
Sunli
bf9e3ec578 Improve depth and complex. 2020-12-18 18:56:28 +08: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
5c293ffdc2 Improve the error message of Tracing extension. 2020-09-26 12:35:28 +08: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
Koxiaet
47259548c4 Support service parsing in async-graphql-parser
- Instead of adding a separate module `schema` like there was before,
since service parsing and executable parsing have a fair amount of
overlap I put them as two submodules `executable` and `service` in both
`parse` and `types`. Also, the grammar is unified under one `.pest`
file.
- Added const equivalents to `Value`, `Directive` etc
- Change the reexport `async_graphql::Value` from
`async_graphql_parser::types::Value` to
`async_graphql_parser::types::ConstValue` since in 99% of cases in this library
a const value is wanted instead of a value.
- Added consistent usage of executable/service instead of the ambiguous
query/schema.
- Some of the tests actually had invalid GraphQL so the new more correct
grammar made them fail, that was fixed.
- Added a `Name` newtype to refer to GraphQL names
(`[A-Za-z_][A-Za-z_0-9]*`) since they are used so frequently.
2020-09-08 09:21:27 +01:00
Koxiaet
81d85c2535 Rewrite async-graphql-parser 2020-09-06 06:38:31 +01:00
Sunli
909ae5e64d Fix input validator is ignored when using variable #207 2020-07-11 10:05:30 +08:00
Sunli
6de85377f7 Rename async_graphql_parser::ast to async_graphql_parser::query 2020-05-15 10:38:48 +08:00
sunli
dc7c8d5280 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
7b85062c6e v1.7.6 2020-04-06 19:57:21 +08:00
sunli
185e1fb8e6 Add some test, modified from juniper 2020-04-05 16:00:26 +08:00
sunli
1b05724390 If the field name or parameter name is wrong, give suggestion 2020-04-03 13:57:24 +08:00
sunli
14860d9b88 Reimplement the error type and remove the dependency on the anyhow::Error 2020-04-02 10:21:04 +08:00
sunli
bf7332378c v1.5.2 2020-03-25 15:07:16 +08:00
sunli
b0369860dd v1.5.1 2020-03-25 11:39:28 +08:00
sunli
0769513c8b v1.5.0
Improve performance
2020-03-24 18:54:22 +08:00
sunli
e6bb9b82ed Add CacheControl for object 2020-03-22 16:45:59 +08:00
sunli
60b0282a89 Support subscription 2020-03-17 17:26:59 +08:00
sunli
abfe861749 Add support for multipart request 2020-03-14 11:46:20 +08:00
sunli
27442145c6 v1.0.0 2020-03-12 17:11:02 +08:00
sunli
ea6e32baf1 add KnownDirectives rule 2020-03-11 10:10:56 +08:00
sunli
feb71eef22 add ProvidedNonNullArguments rule 2020-03-10 20:35:25 +08:00
sunli
de96634f1f add PossibleFragmentSpreads rule 2020-03-10 18:07:47 +08:00
sunli
ecc861de3b add some validation rules 2020-03-10 14:14:09 +08:00
sunli
20d627b838 add some validation rules 2020-03-09 20:39:46 +08:00
sunli
18185ed7a2 v0.10.4 2020-03-09 18:05:52 +08:00
sunli
e20fdc1671 v0.10.2 2020-03-09 12:08:50 +08:00
sunli
0477ea1dd7 v0.10.1 2020-03-08 20:58:22 +08:00
sunli
d7692414ea add some validation code 2020-03-08 20:35:36 +08:00