* Mark `Arc` with `IsInputType` & `IsOutputType`.
We've just updated a service we work with to the latest release of
juniper (it's been on a fairly old master commit for some time). In
this service we have some fields that are contained within `Arc`s, which
I added support for in #479.
Since then it seems the new marker traits of `IsInputType` &
`IsOutputType` have been added, but they do not support `Arc`, leading
to:
```
error[E0277]: the trait bound `Arc<menu::Menu>: IsOutputType<__S>` is not satisfied
--> src/graphql.rs:36:1
|
36 | #[juniper::graphql_object(Context=Context)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IsOutputType<__S>` is not implemented for `Arc<menu::Menu>`
|
= note: required by `juniper::marker::IsOutputType::mark`
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
```
This commit adds support for those, mirroring the support for `Box`.
I'm not sure if there's a good place to add a test for this
functionality so that regressions can be avoided in the future?
* Add Arc tests & FromInputValue for Arc<T>
- add associated type to IntoResolvable and IntoFieldResult traits allowing to name the GraphQLType being resolved
- relax Sized requirement on some IsInputType and IsOutputType impls
* Update compile fail tests for latest Rust
The messages appear to have changed on nightly
* Fix tests depending on fixture data
* Fix more integration test paths
* Fix doc warnings
- add object safe GraphQLValue, GraphQLValueAsync and GraphQLSubscriptionValue traits containing methods for value resolution
- refactor GraphQLType, GraphQLTypeAsync and GraphQLSubscriptionType traits to register and provide GraphQL type information only
- 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>
there is still some weirdness going on. Running async and
non-async tests in `integration_tests/*` works, but running it
from `integration_tests` does not.
* 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 {}
}
```