- make GraphQLUnion trait generic over ScalarValue
- generate generic over ScalarValue impls of GraphQLUnion trait
- add codegen tests with a custom ScalarValue for union macros
- reimplement #[derive(GraphQLUnion)] macro to support:
- both structs and enums
- generics in type definition
- multiple #[graphql] attributes
- external resolver functions
- remove From trait impls generation for enum variants
- reimplement #[graphql_union] macro to support:
- traits
- generics in trait definition
- multiple attributes
- external resolver functions
- GraphQLType implemetation for a raw trait object
- GraphQLTypeAsync implemetation (#549)
- add marker::GraphQLUnion trait
- rewrite "2.5 Unions" section in Book (Juniper user documentation)
- rewrite `codegen` and `codegen_fail` integration tests for GraphQL unions
Additionally:
- re-export `futures` crate in `juniper` for convenient reuse in the generated code without requiring library user to provide `futures` crate by himself (#663)
- use unit type () as default context for EmptyMutation and EmptySubscriptions
- relax Sized trait bound on some GraphQLType and GraphQLTypeAsync definitions, implementations and usages
* Implemented most test cases from the specification
* Unified error handling for all generators
- Removed proc-macro-error -> not required -> use syn::Error
- Everything below lib.rs uses proc_macro2::TokenStream
instead of proc_macro::TokenStream
- Replaced error handling in attribute parsers
* WIP better error messages for *all* macros
* Refactored GraphQLInputObject and minor tweaks
- removed support for Scalar within a string ("DefaultScalarValue")
- removed unraw function and replaced it with the built-in one
- added error messages and return types for all functions within utils
- added more constraints to fulfill the GraphQL spec
* Fixed test-cases which are not compliant with the specification
* Removed unused function
* Added constrains, updated error messages, added marker
* Added argument rename within impl_graphql and fixed `__` tests
* Formatted and cleanup
* Added GraphQLTypeAsync for input object
* Moved codegen tests to separate module
Nightly and stable produce different outputs, thus only test nightly.
* Added IsInputType/IsOutputType traits for type checking
Co-authored-by: Christian Legnitto <LegNeato@users.noreply.github.com>
Fixes#571
Signed-off-by: andrisak <andrisak@gmail.com>
* Replaced the old macro with the new proc macro.
Updated documentation.
Signed-off-by: andrisak <andrisak@gmail.com>
Co-authored-by: Christian Legnitto <LegNeato@users.noreply.github.com>
* Updated implementation of derive enum
- allows context specification
- allows scalar specification
- shares code with derive object
* Added this feature to CHANGELOG
* Added matrix with supported macro attributes for enums
* Added case which checks for custom context
* GraphQLUnion now can use a different context per variant
* Moved context switch test for union into right folder
* Sync resolve expression has the same form as the other impls
* Disabled custom scalar on GraphQLEnum
* Fixed CHANGELOG
* Fixed support matrix of GraphQLEnum in the book
- scalar not supported!
- skip not supported!
* Added test case for "noasync" derive attribute
* Disallowed generics and lifetimes on GraphQLEnum
* Added error message for duplicate naming
* Added error message for empty variant
* Implemented device macro for GraphQLUnion's
* Updated PR link in CHNAGELOG
* Disabled documentation on enumeration fields
* Disabled skip on fields
* Changed implementation for std::convert::Into since skip is not possible
* Added documentation for GraphQLUnion
* Added tests for GraphQLUnion
* Fixed typos in error messages (as suggested by review)
* Fixed failing documentation example
* Utilized `resolver_code` in `util::GraphQLTypeDefinitionField`.
Simplifies code and provides the idea of using
`util::GraphQLTypeDefinitionField` for different types than objects.
* Removed wrong statement about skip annotation in docs.
Co-authored-by: Christian Legnitto <LegNeato@users.noreply.github.com>
Fixes https://github.com/graphql-rust/juniper/issues/534.
I am not sure if the best way is to have folks bring their own futures for the
derives / macros or to pull it in as a dep explicitly like I have done here.
Because people are filing issues, we will do it this way and see what other issues arise.
The trait was introduced while introducing generic scalars, but is not
actually required or useful. It's functionality is fully covered by
methods on the `ScalarValue` trait.
It also forced a lof of for<'a> ScalarRefValue bounds all over the code,
complicating signatures a lot.
It is completely removed now.
* feat: Raw identifier support in object macro
This commit implements raw identifier (`r#name`) support
for field names (methods) and arguments in the `object` proc macro.
Eg:
```rust
impl T {
fn r#type(r#trait: String) -> bool {}
}
```
* Rebase onto master
* Fix merge [skip ci]
This commit implements raw identifier (`r#name`) support
for field names (methods) and arguments in the `object` proc macro.
Eg:
```rust
impl T {
fn r#type(r#trait: String) -> bool {}
}
```
This commit implements a newtype style custom derive
for scalars via `#[derive(GraphQLScalarValue)]`, which now
supports both deriving a base enum scalar type and newtypes.
For newtypes, the `#[graphql(transparent)]` attribute is
required.
This commit:
* implements the derive
* adds integration tests
* updates the book
This commit implements a new proc macro `impl_object` that replaces
the old graphql_object! macro.
The code shares a lot of similarities with the GraphQLObject
custom derive, so the code was unified to handle both
more generically.
Also, doc comment processing was standardized and improved.
Currently, custom derives inside the main juniper crate are supported by
an ugly hack using the __juniper_use_everything macro.
This commit adds new custom derive variants that are for
main juniper crate internal use only (GraphQL{Enum,InputObject}Internal.
All custom derives inside the juniper crate are refactored to use the
new '*Internal' derives.
This allows us to
* remove the use_everything macro,
* simplify the generated code for custom derives
* support the Rust 2018 edition