Commit Graph

148 Commits

Author SHA1 Message Date
Sunli
b98e35995d Supports async websocket initializer. #393 2021-01-16 16:37:20 +08:00
Sunli
b054fc0704 Add Send + Sync constraints for InputType, OutputType and SubscriptionType. 2021-01-14 12:41:59 +08:00
Sunli
46d01db40f Merge branch 'master' into pr/350 2020-12-04 12:17:23 +08:00
Patrick Fernie
e25bcf1c98 use Sec-WebSocket-Protocol header to negotiate protocol 2020-12-03 16:16:07 -05:00
Patrick Fernie
0e711b782e rustfmt fixes 2020-12-02 08:41:12 -05:00
Patrick Fernie
7fb6d7bfbe Add graphql-ws feature for subprotcol selection
On 2020-09-14 a revised version of the [GraphQL over
WebSocket](https://the-guild.dev/blog/graphql-over-websockets) spec was
released as [graphql-ws](https://github.com/enisdenjo/graphql-ws), which
differs from the de facto standard implemented by
[subscriptions-transport-ws](https://github.com/apollographql/subscriptions-transport-ws).

This adds a new `cargo` (non-default) feature, `graphql_ws`, which when enabled utilizes the new protocol spec.

Original [subscriptions-transport-ws
protocol](https://github.com/apollographql/subscriptions-transport-ws/blob/master/PROTOCOL.md)
Revised [graphql-ws
protocol](https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.md)
2020-12-02 08:13:00 -05:00
Sunli
3a0dda2224 Remove the dependency on bytes crate. 2020-11-30 13:43:17 +08:00
Sunli
d3a00571c0 Clippy clean 2020-11-07 08:24:17 +08:00
Sunli
d95fbb42d9 Fixed a bug that websocket could not push data in a situation. 2020-11-06 22:20:12 +08:00
Sunli
c0323002ea 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
Olexiy Buyanskyy
3ac150bef9 removed not needed namespaces 2020-10-23 13:49:00 +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
Olexiy Buyanskyy
bd966d5ba3 Collected all clippy warnings and fixed 2
https://rust-lang.github.io/rust-clippy/master/index.html#inefficient_to_string
https://rust-lang.github.io/rust-clippy/master/index.html#match_wildcard_for_single_variants

Please change `allow` -> `deny` ub src/lib.rs to see other warnings. I feel some of them are important
2020-10-22 09:38:35 +03:00
Koxiaet
12fe7445c7 Replace futures with futures_util 2020-10-16 07:49:22 +01:00
Koxiaet
4caab70113 Require POST for GraphQL requests 2020-10-15 18:42:09 +01:00
Koxiaet
75be2c5d7f Require JSON content-type 2020-10-15 18:30:16 +01:00
Koxiaet
fff84a3170 Support GET requests in actix-web integration 2020-10-15 10:33:38 +01:00
Koxiaet
93c886af07 Make imports consistent 2020-10-15 07:38:10 +01:00
Sunli
87ba51fdd0 Some improvements. 2020-10-10 16:28:07 +08:00
Sunli
97f0b0d419 Merge branch 'master' into rework-errors 2020-10-01 09:07:19 +08:00
Sunli
35f886a7f8 Improve trait for GraphQL types. 2020-09-30 07:45:48 +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
70d2dbc39c Big improvements to tide integration 2020-09-23 18:30:03 +01: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
Sunli
76257403e2 Add support for batch queries. 2020-09-17 19:54:12 +08:00
Koxiaet
e2f53cc30f Document features 2020-09-15 19:32:13 +01:00
Sunli
492bba1cdd Move http::websocket::create and http::websocket::create_with_initializer function to http::WebSocketStream. 2020-09-15 20:07:59 +08:00
Sunli
6b71ba87de Rework websocket
a
2020-09-15 11:49:07 +08:00
Sunli
86a6a34aac http::websocket::create function now returns the WebSocketStream type. 2020-09-15 11:19:00 +08:00
Koxiaet
c2f34b90e5 Rustfmt 2020-09-14 20:20:15 +01:00
Koxiaet
d2b1dd4cab Fix compiling without features 2020-09-14 20:16:41 +01:00
Koxiaet
a3ad1aac30 Remove and feature-gate dependencies 2020-09-14 19:38:41 +01:00
Sunli
1ab5da63ef Improve websocket 2020-09-14 10:44:56 +08:00
Sunli
5bb705bdf3 2.0.0-alpha.5 2020-09-14 09:46:22 +08:00
Sunli
6e5153c8b1 Remove unnecessary memory allocation in websocket. 2020-09-14 08:25:00 +08:00
Koxiaet
6e628031bf 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
8d92454fc3 Support !Unpin in receive_body with pin project 2020-09-13 11:49:07 +01:00
Koxiaet
9796364348 Move websockets to http module and fix doc tests 2020-09-13 07:40:34 +01:00
Koxiaet
dcc7d1be14 Replace http::GQLRequest with Request 2020-09-12 17:07:46 +01:00
Sunli
adcd36a0bf Remove async_graphql::http::StreamBody
l:
2020-09-12 21:44:34 +08:00
Sunli
1320d1ae45 Change MultipartOptions to a builder. 2020-09-12 07:43:50 +08:00
Sunli
049b652dd6 Add transports::websocket module. 2020-09-11 15:54:56 +08:00
Sunli
ec670adb6c Clippy clean 2020-09-11 10:51:20 +08:00
Sunli
91c75ced2a Make all tests passed (async-graphql). 2020-09-10 19:35:48 +08:00
Sunli
22d6e20da3 Merge changes. 2020-09-10 16:54:38 +08:00
Sunli
13f094b67e Merge branch '2.0' of github.com:async-graphql/async-graphql into 2.0 2020-09-10 16:43:24 +08:00
Sunli
f3c0d86f12 Continue to refactor. 2020-09-10 16:39:43 +08:00
Koxiaet
3945599015 Move HTTP functions to HTTP module 2020-09-10 08:04:24 +01:00
Sunli
ce0683e1f9 Initial attempt. 2020-09-10 12:49:08 +08:00
Koxiaet
45a08e9b00 Reorder dependencies and remove dependency on mime 2020-09-09 17:03:33 +01:00
Sunli
ca84859f46 Make all tests pass. 2020-09-06 18:53:24 +08:00
Koxiaet
02f7a5fbbc Remove dependency on serde_derive, satisfy Clippy, improve docs 2020-08-31 19:18:02 +01:00
Sunli
2cf350a5c8 Removes code about streaming requests. 2020-07-31 10:10:03 +08:00
Sunli
ad4013d034 Fix typo 2020-06-22 15:59:53 +08:00
sunli
32210eb64a Fix upload seems broken in the new version. #160 2020-06-07 16:32:05 +08:00
Sunli
edec696610 Add tests for feature attribute 2020-06-06 11:49:29 +08:00
Sunli
4a28518e33 Update playground_source.rs 2020-06-06 10:30:14 +08:00
Sunli
1820e1b723 Clippy cleanup 2020-06-06 10:10:10 +08:00
Roman Useinov
3889f219cd Add the ability to specify full config for GraphQLPlayground (#155)
* add the ability to specify full config for GraphQLPlayground
2020-06-06 09:55:53 +08:00
Sunli
37943fa30a Fix relay @defer requires a label in the second chunk. #146 2020-06-05 12:20:23 +08:00
Sunli
120830b29b Remove Sync for StreamBody 2020-05-21 16:12:18 +08:00
Sunli
788360d6b7 Add StreamResponse support to async-graphql-tide 2020-05-21 14:03:05 +08:00
Sunli
24af597f30 Add StreamResponse type 2020-05-21 11:36:44 +08:00
sunli
7d4150766e Upgrade multer to 1.2.0 2020-05-21 07:43:35 +08:00
sunli
6f924efcf4 Add defer tests 2020-05-20 13:42:55 +08:00
Sunli
75bfba057a Add Deferred type and @defer directive. #51 2020-05-19 20:53:29 +08:00
Sunli
c4ef89e00c Upgrade multer to 1.1.1 2020-05-18 09:32:55 +08:00
sunli
2a63fe1b54 Replace multipart parser with multer. 2020-05-17 16:26:36 +08:00
sunli
8e9aff105e 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
7f7e708614 Move the parser to async-graphql-parser crate. 2020-05-09 22:02:55 +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
11ddf0ae29 Fix typo 2020-04-23 22:54:34 +08:00
sunli
8210ab240a Update graphiql_source.rs 2020-04-22 18:47:20 +08:00
sunli
98cdfd4c42 v1.9.5 2020-04-21 12:13:14 +08:00
sunli
a11248aa95 Add IntoQueryBuilderOpts 2020-04-21 10:14:14 +08:00
sunli
09d5e5f489 v1.9.0 2020-04-14 09:53:17 +08:00
sunli
0b6bfd4c33 Add GQLHttpRequest and IntoQueryBuilder trait 2020-04-11 17:36:05 +08:00
sunli
1b05724390 If the field name or parameter name is wrong, give suggestion 2020-04-03 13:57:24 +08:00
sunli
269f0f0d61 Update error.rs 2020-04-02 14:40:00 +02:00
sunli
506e82895f Add Schema::execute 2020-04-02 12:53:53 +08:00
sunli
cb0ca21a3d Extract line and column from ParseError 2020-04-02 12:37:04 +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
b373e1397d remove PreparedQuery 2020-04-01 16:53:49 +08:00
sunli
a13204273e v1.6.8
Add context data support
2020-03-31 11:19:18 +08:00
Sunli
8b86952e7f Merge pull request #10 from nicolaiunrein/master
ExtendedError and ResultExt inital draft
2020-03-29 23:45:29 +08:00
Nicolai Unrein
5157d95efc ExtendedError and ResultExt inital draft 2020-03-29 16:31:45 +02:00
sunli
9cdd0c45a3 v1.6.4 2020-03-29 20:02:52 +08:00
sunli
bc0d6603c1 v1.6.0 2020-03-26 11:34:28 +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
62b4908ffe v1.3.2 2020-03-20 11:56:08 +08:00
sunli
724cb21258 add GraphQL Cursor Connections 2020-03-19 17:20:12 +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
d7692414ea add some validation code 2020-03-08 20:35:36 +08:00
sunli
cc96dba8d8 add actix-web example 2020-03-05 08:39:56 +08:00