Commit Graph

32 Commits

Author SHA1 Message Date
Sunli
88ba75ec70 Rework connection types 2022-04-19 19:18:06 +08:00
Sunli
c2feefdf09 Fix the problem that some integrations overwritten HTTP headers. #793 2022-01-24 14:14:07 +08:00
Sunli
db83b9440c Update docs 2021-11-20 11:16:48 +08:00
Sunli
bd621f70c1 Make GraphQLWebSocket::new use generic stream.
Add `GraphQLWebSocket::new_with_pair` method.
2021-11-18 09:25:32 +08:00
Sunli
97d7a94489 Update subscription.rs 2021-11-13 16:48:09 +08:00
Sunli
0b09482f5b Update async-graphql-warp 2021-11-12 15:27:05 +08:00
Sunli
206a445b08 Update examples 2021-06-01 17:10:47 +08:00
BratSinot
484a04b5db Removed Copy trait from initializer in graphql_subscription_with_data. 2021-05-31 14:53:00 +03:00
BratSinot
ede6c95e73 cargo fmt 2021-05-31 13:59:10 +03:00
BratSinot
2540e87158 WebSocket is now generic in graphql_subscription_upgrade functions. 2021-05-31 13:55:08 +03:00
Sunli
4003baa2a5 Add async_graphql_warp::graphql_protocol, async_graphql_warp::graphql_subscription_upgrade and async_graphql_warp::graphql_subscription_upgrade_with_data to control WebSocket subscription more finely. 2021-04-05 13:20:02 +08:00
Sunli
a4db80bdc9 Update subscription.rs 2021-04-04 19:51:41 +08:00
BratSinot
9cb9e26b54 Add open / close WebSocket callbacks in warp subscription filter. 2021-04-03 09:04:52 +03:00
D1plo1d
e6da885093 Fixed code formatting 2021-03-31 20:57:39 -04:00
D1plo1d
cfb6246e52 fix: Close, Ping, and Pong websocket messages should not be parsed as GraphQL 2021-03-31 19:40:32 -04:00
Sunli
2d7627cd39 Fixed GraphQL over WebSocket Protocol does not support ConnectionError events. #406 2021-02-06 11:02:41 +08:00
Sunli
1a6da611e8 Fix tests. 2021-01-20 10:37:31 +08:00
Sunli
b98e35995d Supports async websocket initializer. #393 2021-01-16 16:37:20 +08:00
Patrick Fernie
6f3e861e27 support client specifying multiple protocols in Sec-WebSocket-Protocol negotiation 2020-12-04 12:16:14 -05:00
Patrick Fernie
e25bcf1c98 use Sec-WebSocket-Protocol header to negotiate protocol 2020-12-03 16:16:07 -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
e1be5d5537 Fix typo 2020-10-22 10:11:47 +08:00
Sunli
e3d693da28 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
Koxiaet
12fe7445c7 Replace futures with futures_util 2020-10-16 07:49:22 +01:00
Sunli
43bf61754a Fixed all tests. 2020-10-16 09:01:19 +08:00
Koxiaet
71ed676039 Improve Warp integration
This contains a breaking change; BadRequest now contains a
ParseRequestError instead of an anyhow::Error, so it's implementation is
what the documentation says. I'm not sure whether it's worth bumping
the major version number though.
2020-10-15 14:18:57 +01:00
Sunli
97f0b0d419 Merge branch 'master' into rework-errors 2020-10-01 09:07:19 +08:00
Koxiaet
768b666acd Merge master 2020-09-30 18:24:24 +01: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
Sunli
e60864a18d Rework async-graphql-derive. #288 2020-09-29 16:06:10 +08:00
Sunli
e12ae8b236 Add BatchRequest support for actixweb and warp integrations. 2020-09-21 14:57:33 +08:00