Commit Graph

260 Commits

Author SHA1 Message Date
Sunli
f9f60d31ec Configurable case conversion. 2020-10-14 19:16:10 +08:00
Sunli
12f15f4815 2.0.2 2020-10-14 11:11:52 +08:00
Sunli
6958202238 Update docs 2020-10-13 10:19:30 +08:00
Sunli
25af42ed81 Improve performance 2020-10-12 14:49:32 +08:00
Sunli
a1e57eb4a8 All merged objects will no longer be removed. #308 2020-10-12 11:04:01 +08:00
Sunli
c777150dcd Use value! instead of serde_json::json!. 2020-10-12 10:17:05 +08:00
Sunli
e056edbaa0 Add parse_value and from_value funcntions. 2020-10-11 20:24:31 +08:00
Sunli
87ba51fdd0 Some improvements. 2020-10-10 16:28:07 +08:00
Sunli
22f7e09537 Fix typo. #297 2020-10-04 07:49:56 +08:00
sunli
cb2139afcd Remove useless code. 2020-10-01 18:48:11 +08:00
Sunli
97f0b0d419 Merge branch 'master' into rework-errors 2020-10-01 09:07:19 +08:00
Koxiaet
4b20a21783 Fix compilation and tests 2020-09-30 19:40:17 +01: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
0d6771a199 Add some type detection to make the defined schema conform to the GraphQL specification. #282 2020-09-27 15:35:05 +08:00
Sunli
089e830d26 Add StringNumber type. 2020-09-26 09:22:54 +08:00
Sunli
5eef10a1c4 Make uuid to optional dependent. 2020-09-25 15:40:04 +08:00
Sunli
8a82954f0b Improve tracing 2020-09-25 15:01:55 +08:00
Sunli
312b8f13d8 Add Schema::sdl method. #191 2020-09-23 14:14:22 +08:00
Sunli
7eb2143b2c Implement Serialize/Deserialize for MaybeUndefine<T>. 2020-09-21 15:22:45 +08:00
Sunli
e12ae8b236 Add BatchRequest support for actixweb and warp integrations. 2020-09-21 14:57:33 +08:00
William Myers
b1763de1ea Remove Deserialize impl from MaybeUndefined
Change Serialize implementation to use the `untagged` attribute.
This handles the common case of directly serializing `MaybeUndefined`,
but deserializing into an `Option<T>`. We could add a more sophisticated
custom deserialize implementation later.
2020-09-20 13:22:51 -07:00
William Myers
c117cc0bf5 Add more trait implementations to MaybeUndefined
Closes #267
2020-09-19 14:10:54 -07:00
Sunli
73333035bd Fix compiling without features 2020-09-18 15:14:40 +08:00
Sunli
45dc3d6d09 Add Upload::into_async_read with blocking 2020-09-18 14:32:00 +08:00
Sunli
e645e9d999 Remove the GQL prefix of all macros. #208 2020-09-18 09:10:24 +08:00
Sunli
76257403e2 Add support for batch queries. 2020-09-17 19:54:12 +08:00
Sunli
34eaa1d686 Some improvements. 2020-09-17 11:22:09 +08:00
Koxiaet
e2f53cc30f Document features 2020-09-15 19:32:13 +01:00
Koxiaet
c546b87de6 Improved serialize_resp 2020-09-14 19:56:12 +01:00
Koxiaet
a3ad1aac30 Remove and feature-gate dependencies 2020-09-14 19:38:41 +01:00
Sunli
42817a3aa6 Implement Type for more stdlib collection types #189
Implement InputValueType/OutputValueType for HashSet<T>/BTreeSet<T>/VecDeque<T>/LinkedList<T>
Implement ScalarType for char/NonZero*/HashMap<String,T>/BTreeMap<String, T>
2020-09-14 20:06:44 +08:00
Sunli
01f02c6bc1 Fix the problem that the compilation fails when the compilation parameter is --no-default-features.
Update mod.rs
2020-09-14 09:54:55 +08:00
Sunli
5bb705bdf3 2.0.0-alpha.5 2020-09-14 09:46:22 +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
6cf7e78ea9 Restructure types module 2020-09-13 10:38:19 +01:00
Koxiaet
d4eed93ad4 Remove unused idx parameter on subscription 2020-09-13 08:13:56 +01:00
Sunli
24b80d52d3 Remove all attribute macros that can be replaced by derive. 2020-09-13 11:41:15 +08:00
Koxiaet
b8add03d53 Remove Deref for ContextBase 2020-09-12 17:42:15 +01:00
Koxiaet
35e74a4e17 Create resolver_utils 2020-09-12 10:29:52 +01:00
Sunli
35f17a389c Remove unnecessary Result on Schema::execute_stream function. 2020-09-11 10:47:55 +08:00
Sunli
91c75ced2a Make all tests passed (async-graphql). 2020-09-10 19:35:48 +08:00
Sunli
f3c0d86f12 Continue to refactor. 2020-09-10 16:39:43 +08:00
Sunli
53a7314666 Rustfmt 2020-09-10 09:09:55 +08:00
Koxiaet
f770501557 Remove anyhow, byteorder and base64 dependencies 2020-09-09 17:34:23 +01:00
Koxiaet
2f80e484d1 Fix Tide tests 2020-09-08 11:07:32 +01:00
Koxiaet
ea7e4eaf2a Fix tests 2020-09-08 10:19:25 +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
c055736101 Rustfmt 2020-09-06 07:16:36 +01:00
Koxiaet
81d85c2535 Rewrite async-graphql-parser 2020-09-06 06:38:31 +01:00
Sunli
6a38057a22 Implements Default for Schema. 2020-08-28 14:19:35 +08:00
Sunli
c35eecd90d Merge subscriptions #243 2020-08-27 15:35:48 +08:00
Sunli
6bf9718225 Update docs 2020-08-10 14:57:45 +08:00
Sunli
b0403f4e99 Add Default impl for MergedObject. #231 2020-08-10 10:47:30 +08:00
Sunli
4b6bb38e83 Add MergedObject type. #231 2020-08-09 15:03:10 +08:00
Sunli
2cf350a5c8 Removes code about streaming requests. 2020-07-31 10:10:03 +08:00
Sunli
4d3851e1b5 Replace log crate with xlog. 2020-07-15 18:05:24 +08:00
Sunli
665b337bf2 Remove all datasource-related code and update the documentation. 2020-06-15 14:17:19 +08:00
Sunli
1b8de3b433 Remove connection::DataSource 2020-06-15 12:06:15 +08:00
Sunli
7b09aaf70b Fix slice support #165 2020-06-09 18:45:22 +08:00
William Myers
422337fd1e Add docs about into_read being blocking
Addresses #151
2020-06-07 20:44:01 -06:00
Sunli
1820e1b723 Clippy cleanup 2020-06-06 10:10:10 +08:00
Coenen Benjamin
437a677948 Update FnMut to FnOnce for query closure 2020-06-06 02:00:21 +02:00
Sunli
37943fa30a Fix relay @defer requires a label in the second chunk. #146 2020-06-05 12:20:23 +08:00
Sunli
ef6ed9aae5 Update connection::query docs 2020-06-02 21:43:08 +08:00
Sunli
c41dba50bc Add example for connection::query 2020-06-02 19:12:28 +08:00
Sunli
2452a44484 Add connection::query function 2020-06-02 17:43:13 +08:00
Sunli
9eff1da4ae Remove premature generic constraints of DataSource type. 2020-05-29 12:42:58 +08:00
Sunli
dba575d4a5 Add Connection::map and Connection::map_node functions 2020-05-29 12:19:08 +08:00
Sunli
6361bc4532 Update connection_type.rs 2020-05-29 11:56:12 +08:00
Sunli
38db0cbec5 Update DataSource example 2020-05-29 11:54:16 +08:00
Sunli
a2239fd51c Rename Connection::new_with_additional_fields to Connection::with_additional_fields and Edge::new_with_additional_fields to Edge::with_additional_fields 2020-05-29 10:28:18 +08:00
Sunli
6cc92458e1 Add Connection::try_append and Connection::try_append_stream 2020-05-29 09:24:31 +08:00
sunli
e98327ae5e Update some docs 2020-05-28 22:18:15 +08:00
Sunli
43c8daa132 Add MaybeUndefined type (#123)
* Add MaybeUndefined type
2020-05-28 15:00:55 +08:00
Sunli
76ff909ccd New data source (#105)
* New data source
2020-05-28 08:02:00 +08:00
sunli
d53eb1a9ff Fix Service type name error. 2020-05-27 18:07:38 +08:00
Sunli
a9d3ac9cf8 Implement a type-safe default value definition for InputValue. #111 2020-05-26 20:43:53 +08:00
Samuel Hurel
f9249e403f Add proper count for Stream DataSource impl 2020-05-21 14:02:21 +02:00
Samuel Hurel
d58fd6e942 Remove StreamDataSource wrapper 2020-05-21 13:10:36 +02:00
Samuel Hurel
a7a17a43ad Add doc 2020-05-21 11:45:15 +02:00
Samuel Hurel
1f4b732615 Fix tests & impl From<Stream> for StreamDataSource 2020-05-21 10:22:36 +02:00
Samuel Hurel
3aac2160e0 Remove StreamDataSource mapping closure 2020-05-21 09:55:49 +02:00
Samuel Hurel
02de780921 Stream connection 2020-05-21 09:40:42 +02:00
Sunli
bcd39f4df8 Remove Clone bound for Deferred and Streamed 2020-05-21 15:38:26 +08:00
Sunli
326fac2799 Add @stream directive 2020-05-21 10:12:54 +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
d00e3e8c25 The scalar name and description attributes are placed on the process macro attributes. #97 2020-05-19 13:27:01 +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
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
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
0e371afb3c It not finished yet. 2020-05-11 17:13:50 +08:00
Samuel Hurel
05cac5854f impl From<ID> for Cursor 2020-05-10 16:25:16 +02:00
Samuel Hurel
c810764e7e Simplify ID conversion 2020-05-10 15:52:47 +02:00
Samuel Hurel
d3015e9814 Simplify cursor conversion 2020-05-10 14:49:52 +02:00
sunli
ff6f97d7df Add ToGraphQLCursor and ToGraphQLID traits. #54 2020-05-10 18:39:53 +08:00
sunli
728989209f The error reason can be returned when the input value is parsed incorrectly. #70 2020-05-10 18:27:46 +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
Blaine Bublitz
c678dde4be Allow datasource to use context 2020-05-06 17:04:26 -07:00
sunli
64aee618fc Make PageInfo available from outside (#52) 2020-05-06 06:52:04 +08:00
sunli
35531b65f8 Change the first parameter of OutputValueType::resolve to be &self 2020-05-05 21:06:48 +08:00
Blaine Bublitz
e4101db924 Relay pagination algorithm 2020-05-05 00:22:01 -07:00
sunli
d7ea05ab14 Add tests to limit complexity and depth. 2020-05-05 13:46:56 +08:00
Blaine Bublitz
eaa50a52e0 Add Cursor scalar (#48)
* Add Cursor scalar
2020-05-05 13:21:45 +08:00
sunli
220cd1e775 Report subscription stream errors to the client. 2020-05-03 16:02:46 +08:00
sunli
3f49ebce0e Move project to async-graphql 2020-04-28 15:41:31 +08:00
sunli
4659da9c30 fix #33 2020-04-27 12:57:52 +08:00
sunli
a4b4e69ea7 Remove the redundant field parameter for OutputType::resolve_field. 2020-04-26 15:12:18 +08:00
sunli
70b8ecc311 Update connection_type.rs 2020-04-26 14:40:55 +08:00
sunli
88f6e468e7 Some minor changes 2020-04-26 12:34:08 +08:00
nicolaiunrein
248e29c40b Fix url linking from Upload to example. 2020-04-20 07:59:10 +02:00
sunli
4cf83e333b Add some docs
v1.9.2
2020-04-17 11:06:33 +08:00
sunli
a53e61abf9 v1.8.1 2020-04-11 17:40:29 +08:00
sunli
0b6bfd4c33 Add GQLHttpRequest and IntoQueryBuilder trait 2020-04-11 17:36:05 +08:00
sunli
86bdb422b1 Add federation support 2020-04-09 22:03:09 +08:00
sunli
5c710ff744 Add SimpleBroker 2020-04-07 14:30:46 +08:00
sunli
b88ac80084 The subscription field now returns a stream 2020-04-06 13:49:39 +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
c60e4a51ab Fixed panic when uploading binary file 2020-04-03 09:27:22 +08:00
sunli
506e82895f Add Schema::execute 2020-04-02 12:53:53 +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
nicolaiunrein
3a3dfcc67e Update upload.rs 2020-03-30 16:47:17 +02:00
nicolaiunrein
4ec15b0749 Update upload.rs 2020-03-30 16:36:27 +02:00
nicolaiunrein
cea92039c5 Update upload.rs 2020-03-30 16:31:38 +02:00
Nicolai Unrein
441d163e93 add documentation to upload 2020-03-30 16:25:35 +02:00
sunli
bc0d6603c1 v1.6.0 2020-03-26 11:34:28 +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
788a3b558b v1.4.2 2020-03-22 09:34:32 +08:00
sunli
99f4184f83 Clippy cleanup 2020-03-21 09:32:13 +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
41f6d5fcc0 v1.2.1
subscription support directive and fragment
2020-03-18 11:13:45 +08:00
sunli
f41123c7da v1.2.0 2020-03-17 19:11:14 +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
18185ed7a2 v0.10.4 2020-03-09 18:05:52 +08:00
sunli
d7692414ea add some validation code 2020-03-08 20:35:36 +08:00
sunli
f4760ac1e5 Update optional.rs 2020-03-07 12:39:34 +08:00
sunli
b4edae7981 Added support for inline fragment 2020-03-07 10:39:55 +08:00
sunli
69b3dea88c implemented interface 2020-03-06 23:58:43 +08:00
sunli
b0e7a63a8d Update optional.rs 2020-03-06 08:42:06 +08:00