Commit Graph

155 Commits

Author SHA1 Message Date
Sunli
b124382e9c Add SchemaBuilder::override_description function. 2020-10-27 10:06:10 +08:00
Sunli
c999dd26dd Fix typo 2020-10-22 10:11:47 +08:00
Sunli
776aadf169 Add entity lookup support for MergedObject.
Add some GraphQL specification constraints for all derived macros.

Use `Registry::create_dummy_type` to create a merged type.
2020-10-20 11:49:31 +08:00
Sunli
7510741311 Fix the bug that ʻExtension::prepare_request` cannot get the correct request data through the context.
Add test code for extension.
2020-10-18 11:24:16 +08:00
Koxiaet
db312a372d Replace futures with futures_util 2020-10-16 07:49:22 +01:00
Koxiaet
4e562a86a7 Avoid locking extensions mutex when possible 2020-10-16 06:52:52 +01:00
Koxiaet
a48953899c Remove itertools dependency 2020-10-16 06:37:48 +01:00
Sunli
985ee939d4 Add Schema::names function. 2020-10-15 19:36:54 +08:00
Koxiaet
d34ac0ba08 Make imports consistent 2020-10-15 07:38:10 +01:00
Sunli
6dd9483762 Improve performance 2020-10-12 14:49:32 +08:00
Sunli
10cd868f4c Some improvements. 2020-10-10 16:28:07 +08:00
Sunli
1e30712726 Merge branch 'master' into rework-errors 2020-10-01 09:39:47 +08:00
Sunli
e6108352b9 Merge branch 'master' into rework-errors 2020-10-01 09:07:19 +08:00
Koxiaet
b61088089b Fix compilation and tests 2020-09-30 19:40:17 +01:00
Koxiaet
ab82460b81 Merge master 2020-09-30 18:24:24 +01:00
Sunli
fd4c2b193b Added Apollo persisted queries extension. #280 2020-09-30 11:37:12 +08:00
Sunli
6492629e71 Improve trait for GraphQL types. 2020-09-30 07:45:48 +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
af2e480b70 Added context for Extension. 2020-09-29 20:47:37 +08:00
Sunli
4bbb30b2ae Update schema.rs 2020-09-27 19:13:12 +08:00
Sunli
e9efad4479 Fix the problem when generating Federation SDL. #283 2020-09-27 18:49:04 +08:00
Sunli
39f8a4fa17 Invoke extensions for execute_schema. 2020-09-26 15:52:59 +08:00
Sunli
e3125b2d2d Add Schema::sdl method. #191 2020-09-23 14:14:22 +08:00
Koxiaet
203ea4ad64 Merge branch 'master' of github.com-koxiaet:async-graphql/async-graphql into master 2020-09-22 20:03:33 +01: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
Sunli
fa10a55745 Add Request::extension method. #271 2020-09-21 15:53:07 +08:00
Koxiaet
5cf527aeef Merge branch 'master' of github.com-koxiaet:async-graphql/async-graphql into master 2020-09-17 19:23:15 +01:00
Koxiaet
88be6bca61 Improve websockets 2020-09-17 19:22:54 +01:00
Sunli
acc1a6f515 Add support for batch queries. 2020-09-17 19:54:12 +08:00
Sunli
d67a511a07 2.0.0-alpha.5 2020-09-14 09:46:22 +08:00
Koxiaet
d404e756bc Rework subscriptions
The main change in this commit is changing the return type of
SubscriptionType::create_stream from
Future<Result<Stream<Result<Response>>>> to just Stream<Result<Json>>. I
also allowed the returned stream to borrow from self and context.
2020-09-13 18:52:36 +01:00
Koxiaet
8796c5e1a7 Replace http::GQLRequest with Request 2020-09-12 17:07:46 +01:00
Koxiaet
1aa36819eb Create resolver_utils 2020-09-12 10:29:52 +01:00
Sunli
a93b91ae2d Re-enable the test on websocket. 2020-09-11 16:41:56 +08:00
Sunli
faac753096 Add transports::websocket module. 2020-09-11 15:54:56 +08:00
Sunli
553e6ffd53 Remove unnecessary Result on Schema::execute_stream function. 2020-09-11 10:47:55 +08:00
Sunli
c88747dfe4 Make all tests passed (async-graphql). 2020-09-10 19:35:48 +08:00
Sunli
7a90069cad Continue to refactor. 2020-09-10 16:39:43 +08:00
Sunli
9bc837da9e Initial attempt. 2020-09-10 12:49:08 +08:00
Koxiaet
ed5acdcf18 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
9ad4e8c1a8
Merge branch 'master' into master 2020-09-06 07:20:18 +01:00
Koxiaet
3bf5f3a16c Rustfmt 2020-09-06 07:16:36 +01:00
Koxiaet
e3e58d261d Rewrite async-graphql-parser 2020-09-06 06:38:31 +01:00
Sunli
2aca257136 Remove unnecessary memory allocation. 2020-09-02 14:27:04 +08:00
Sunli
80b2ff00c5 Implements Default for Schema. 2020-08-28 14:19:35 +08:00
Sunli
2e5c256de9 Rename SubscriptionTransport to ConnectionTransport. #240 2020-08-15 08:47:45 +08:00
Sunli
a193a8e51a Add directive @ifdef 2020-08-06 14:52:54 +08:00
Sunli
3d7594bac1 Removes code about streaming requests. 2020-07-31 10:10:03 +08:00
Sunli
8992b681dc Fix input validator is ignored when using variable #207 2020-07-11 10:05:30 +08:00
Sunli
09a6eb4944 Extension::Logger now provides more comprehensive error information. 2020-06-13 22:14:47 +08:00
Sunli
9af4d2b5ad Add QueryBuilder::extension function. #87 2020-06-05 15:42:29 +08:00
Sunli
616b7303ee Add SchemaBuilder::enable_federation #136 2020-06-02 08:49:27 +08:00
sunli
f9f9cdfb20 Logger extensions filter out introspection. #87 2020-05-27 20:47:22 +08:00
Sunli
9294c170e2 Fix potential security issues with subscription connections. 2020-05-26 13:35:13 +08:00
Sunli
d719461ae5 Add logger extension 2020-05-22 11:58:49 +08:00
Sunli
01489e20a5 Add StreamResponse type 2020-05-21 11:36:44 +08:00
Sunli
4868cf242b Add @stream directive 2020-05-21 10:12:54 +08:00
sunli
a745667922 Add @defer support for actix-web 2020-05-20 20:10:40 +08:00
sunli
87c6d31907 Solve problem #99 2020-05-20 15:44:59 +08:00
sunli
e949cb441c Add defer tests 2020-05-20 13:42:55 +08:00
Sunli
d300e27fa2 Add Deferred type and @defer directive. #51 2020-05-19 20:53:29 +08:00
sunli
273aecb6bf Update schema.rs 2020-05-19 00:03:15 +08:00
sunli
42a4639dc3 Preserve field order for introspection. #89 2020-05-16 10:05:48 +08:00
Sunli
9184c999ae Modify some type names (internal types) 2020-05-15 10:08:37 +08:00
sunli
01b2ce8e18 Improve GraphQL query parser performance. #76 2020-05-12 16:27:06 +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
95c6c0bbf3 Report subscription stream errors to the client. 2020-05-03 16:02:46 +08:00
sunli
1a4189e3e0 Fixed a bug that caused the subscription request to fail to receive any messages. #45 2020-05-03 10:06:17 +08:00
sunli
4484d33f4e Add some test 2020-05-03 09:12:14 +08:00
sunli
998e9b7b85 Websocket transport creates context data from the connect_init.payload property 2020-04-23 14:52:22 +08:00
sunli
09624cab24 v1.9.11
Add context data for subscription
2020-04-23 10:26:16 +08:00
sunli
f7a2fe5fa5 Add SchemaBuilder::register_type method 2020-04-21 20:47:48 +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
d3adeb79b1 Add SimpleBroker 2020-04-07 14:30:46 +08:00
sunli
3ac07990bb v1.7.6 2020-04-06 19:57:21 +08:00
sunli
efad20d4c4 Add subscription test 2020-04-06 18:30:38 +08:00
sunli
631de52400 The subscription field now returns a stream 2020-04-06 13:49:39 +08:00
sunli
d1abad5127 If the field name or parameter name is wrong, give suggestion 2020-04-03 13:57:24 +08:00
sunli
fda683c931 Add Schema::execute 2020-04-02 12:53:53 +08:00
sunli
10105b8a09 Reimplement the error type and remove the dependency on the anyhow::Error 2020-04-02 10:21:04 +08:00
sunli
01ec88abf5 remove PreparedQuery 2020-04-01 16:53:49 +08:00
sunli
3938c2f80c v1.6.8
Add context data support
2020-03-31 11:19:18 +08:00
sunli
ba64ecc31d v1.6.4 2020-03-29 20:02:52 +08:00
sunli
50347bc415 v1.6.0 2020-03-26 11:34:28 +08:00
sunli
457e30ea2f v1.5.2 2020-03-25 15:07:16 +08:00
sunli
934038150e v1.4.2 2020-03-22 09:34:32 +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
6ae0a9a5f6 Update schema.rs 2020-03-15 15:32:54 +08:00
sunli
f78a172241 Add support for multipart request 2020-03-14 11:46:20 +08:00
sunli
482c5b3cf3 v0.10.4 2020-03-09 18:05:52 +08:00
sunli
53dcd0aae5 add some validation code 2020-03-08 20:35:36 +08:00
sunli
426d7923dc implemented union type 2020-03-08 09:21:29 +08:00
sunli
70322b9a37 implemented interface 2020-03-06 23:58:43 +08:00
sunli
2351e75f2c fix some bug
add starwars example
2020-03-05 21:34:31 +08:00
sunli
b3340680ba v0.8.0 2020-03-05 17:06:14 +08:00