Commit Graph

73 Commits

Author SHA1 Message Date
Sunli
88ba75ec70 Rework connection types 2022-04-19 19:18:06 +08:00
Sunli
5dad855f8e Export @oneOf directive to SDL when Oneof type is defined. #766 2022-03-05 09:06:59 +08:00
Sunli
a4b840a984 Add support for oneof field on object. #766 2022-03-04 21:24:17 +08:00
Sunli
7dfebf99fd Fix possible stack overflow in validator. 2022-01-28 09:46:14 +08:00
SadiinsoSnowfall
61e80c869e Fixed formatting (missing comma) 2022-01-24 14:32:30 +01:00
SadiinsoSnowfall
892cf8169e Fixed formatting (hopefully for the last time) 2022-01-24 14:27:38 +01:00
SadiinsoSnowfall
09918299c1 Fixed formatting (2) 2022-01-24 14:24:33 +01:00
SadiinsoSnowfall
aab3edc459 Fixed formatting 2022-01-24 14:23:06 +01:00
SadiinsoSnowfall
962e1b1f80 Fixed variable type not checked when given a default value 2022-01-24 14:11:46 +01:00
Sunli
e2c6ead1a3 Add DirectivesUnique rule 2021-11-18 20:14:56 +08:00
Sunli
eb022a0cca Rework validators 2021-11-14 21:09:14 +08:00
Sunli
057d6aebfd Subscription typename - [GraphQL - October 2021] #681 2021-11-02 20:35:05 +08:00
Rodgers
53c4945fc4 Update AND, OR, and MapErr logic. Update logic for object input 2021-07-08 23:43:12 +07:00
Rodgers
aa1d4194b5 Add is_valid_with_extensions 2021-07-08 21:37:38 +07:00
Rodgers
c0d24be0c7 Add report_error_with_extensions 2021-07-08 20:02:49 +07:00
Sunli
2dce1ad35f Clippy clean 2021-06-18 10:43:34 +08:00
Sunli
4c34494e52 Fix the problem that the validation does not work on some inline fragments. 2021-03-14 10:15:52 +08:00
Sunli
4f2ea5ed50 Moved Variables from async_graphql::context::Variables to
`async_graphql::Variables`.
2021-02-28 09:37:42 +08:00
Sunli
144ddb752c Clippy clean 2021-02-26 20:05:09 +08:00
Olexiy Buyanskyy
9f442aa750 removed not needed namespaces 2020-10-23 13:51:09 +03:00
Olexiy Buyanskyy
baf67f3344 Fixed redundant_closure_for_method_calls
https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure_for_method_calls
2020-10-23 11:10:00 +03:00
Koxiaet
93c886af07 Make imports consistent 2020-10-15 07:38:10 +01:00
Sunli
12f15f4815 2.0.2 2020-10-14 11:11:52 +08:00
Sunli
e056edbaa0 Add parse_value and from_value funcntions. 2020-10-11 20:24:31 +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
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
20d240df47 Fix enum strings in query variables are not converted to proper enums. #270 2020-09-20 13:28:18 +08:00
Koxiaet
f9ce6118b2 Merge branch 'master' of github.com-koxiaet:Koxiaet/async-graphql into master 2020-09-08 09:32:37 +01:00
Koxiaet
04c898ef01 Rustfmt 2020-09-08 09:30:29 +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
Sunli
e2c9de9183 Clippy cleanup 2020-09-06 18:59:38 +08:00
Sunli
ca84859f46 Make all tests pass. 2020-09-06 18:53:24 +08:00
Koxiaet
c055736101 Rustfmt 2020-09-06 07:16:36 +01:00
Koxiaet
81d85c2535 Rewrite async-graphql-parser 2020-09-06 06:38:31 +01:00
Koxiaet
02f7a5fbbc Remove dependency on serde_derive, satisfy Clippy, improve docs 2020-08-31 19:18:02 +01:00
Sunli
47174966fb Add directive @ifdef 2020-08-06 14:52:54 +08:00
Sunli
503339f504 InputValueValidator::is_valid function now returns the Result type. #221 2020-07-30 09:43:51 +08:00
Sunli
909ae5e64d Fix input validator is ignored when using variable #207 2020-07-11 10:05:30 +08:00
Sunli
e76dcb94da Remove unsafe code from tests 2020-05-29 17:29:15 +08:00
sunli
c16d239b65 Remove some unsafe code 2020-05-16 21:14:26 +08:00
sunli
10a8b71adb Preserve field order for introspection. #89 2020-05-16 10:05:48 +08:00
Sunli
6de85377f7 Rename async_graphql_parser::ast to async_graphql_parser::query 2020-05-15 10:38:48 +08:00
Sunli
f74652e61a Modify some type names (internal types) 2020-05-15 10:08:37 +08:00
sunli
8299a54456 Improve GraphQL query parser performance. #76 2020-05-12 16:27:06 +08:00
sunli
bc2966bc0d Improve parser performance. 2020-05-10 10:59:51 +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
ed85c85bf4 Add subscription test 2020-04-06 18:30:38 +08:00
sunli
79f46843aa v1.7.4 2020-04-05 16:14:22 +08:00
sunli
185e1fb8e6 Add some test, modified from juniper 2020-04-05 16:00:26 +08:00