Commit graph

222 commits

Author SHA1 Message Date
Graeme Coupar
824cd4081b
Update juniper_codegen for syn 1.0.60 (#861)
* Update juniper_codegen for syn 1.0.60

syn 1.0.60 has updated it's `Type::__Nonexhaustive` to
`Type::TestExhaustive`, breaking juniper.  This updates juniper to use
the recommended idiom for doing exhaustive matching on `Type`, which
fixes this.

Not entirely clear if we need exhaustive matching here or if we could
just use a fallback, but this fixes the build at least.

Also updated the minimum syn so users have to pull it in

* Update example to use relative deps

As otherwise CI fails on this branch
2021-01-26 07:41:03 -10:00
Christian Legnitto
186186a603 Release juniper 0.15.2 2021-01-15 19:46:23 -10:00
Christian Legnitto
948517b84f Release juniper_codegen 0.15.2 2021-01-15 19:44:23 -10:00
Christian Legnitto
b2a3b097bd Release juniper 0.15.1 2020-12-12 09:48:31 -10:00
Christian Legnitto
f1f64446b5 Release juniper_codegen 0.15.1 2020-12-12 09:47:47 -10:00
Christian Legnitto
0c83ffde2a
Fix release replacements. (#825)
Some crates need to rewrite values when they are released in other crates. It turns out, by default we use a general config _build/release.toml. So it turns out these local-to-the-crate release.tomls were not being used unless explicitly chosen in the local-to-the-crate Makefile.toml. This removes the dead release.tomls and overrides the ones that need to edit other crates on release.
2020-12-11 19:20:05 -10:00
Christian Legnitto
6326acde33
Fix some clippy lints (#809) 2020-12-10 21:41:23 -10:00
Christian Legnitto
bfe627e573 Release juniper 0.15.0 2020-12-09 19:19:43 -10:00
Christian Legnitto
d63fdef321 Release juniper_codegen 0.15.0 2020-12-09 19:19:00 -10:00
Zak
4ffd276a5b
Allow raw identifier for field arguments in #[graphql_object] macro (#812, #786) 2020-11-26 12:46:06 +02:00
Jonas Meurer
cb6d89f4c7
Allow different Scalar for GraphQLScalarValue (#807)
* allow setting scalar in macro

* rustfmt

* added changes to changelog

* added test cases
2020-11-15 17:15:55 -10:00
Kai Ren
3472fe6d10
Fix attributes naming on fields and arguments for interfaces and unions (#806)
Additionally:
- revive macros/tests/object
- revive executor_tests/interfaces_unions
2020-11-14 15:41:01 +02:00
tyranron
bcbf44ecbd
Make GraphQL interface value enum variants named after the type they contain 2020-11-09 14:07:33 +01:00
tyranron
4dbd740fef
Fix missing docs for enum variants generated for dispatching GraphQL interface values 2020-11-09 13:40:24 +01:00
Kai Ren
a4871887bb
Default to generic ScalarValue in #[graphql_object] macro (#779)
* Change codegen ScalarValue defaults for #[graphql_object] macro

* Fix integration tests

* Fix codegen failure tests

* Fix 'juniper' crate tests

* Fix integration crates tests

* Fix 'juniper_benchmarks' crate

* Fix examples

* Fix Book

* Fix

* Add CHANGELOG entry

* Some Book corrections

* Fix

* Bootstrap coercion machinery

* Reimpl coercion

* Correct tests, vol.1

* Correct tests, vol.2

* Correct tests, vol.3

* Correct tests, vol.4

* Correct tests, vol.5

* Fix coercion for subscriptions

* README fixes

Co-authored-by: Christian Legnitto <christian@legnitto.com>
Co-authored-by: Christian Legnitto <LegNeato@users.noreply.github.com>
2020-11-06 18:15:18 -08:00
Chris
cd66bdb450
Add ability to distinguish between implicit and explicit null (#795)
* add Nullable to distinguish between implicit and explicit null

* cargo fmt

* add page to book

* address comment
2020-10-23 19:21:37 -04:00
Kai Ren
421b343398
Remove redundant extern crate usages (#790)
Additionally:
- remove obsolete benches in benches/ dir
- restore benches in juniper/benches/ dir
2020-10-19 19:42:27 +03:00
nirmangupta
5832b3696d
Support chrono-tz::Tz GraphQL scalar (#519)
Co-authored-by: Nirman Gupta <nirmangupta@gmail.com>
Co-authored-by: Kai Ren <tyranron@gmail.com>
2020-10-19 15:30:17 +03:00
Igor Pashev
c964fd805c
Allow disabling case conversion (#765) 2020-10-13 12:34:36 -04:00
tyranron
6d4a0a8709
Fill up missing docs for #[graphql_interface] macro (#682) 2020-10-07 10:09:01 +02:00
Kai Ren
cbf16c5a33
Make interfaces great again! (#682)
* Bootstrap

* Upd

* Bootstrap macro

* Revert stuff

* Correct PoC to compile

* Bootstrap #[graphql_interface] expansion

* Bootstrap #[graphql_interface] meta parsing

* Bootstrap #[graphql_interface] very basic code generation [skip ci]

* Upd trait code generation and fix keywords usage [skip ci]

* Expand trait impls [skip ci]

* Tune up objects [skip ci]

* Finally! Complies at least... [skip ci]

* Parse meta for fields and its arguments [skip ci]

- also, refactor and bikeshed new macros code

* Impl filling fields meta and bootstrap field resolution [skip ci]

* Poking with fields resolution [skip ci]

* Solve Rust's teen async HRTB problems [skip ci]

* Start parsing trait methods [skip ci]

* Finish parsing fields from trait methods [skip ci]

* Autodetect trait asyncness and allow to specify it [skip ci]

* Allow to autogenerate trait object alias via attribute

* Support generics in trait definition and asyncify them correctly

* Temporary disable explicit async

* Cover arguments and custom names/descriptions in tests

* Re-enable tests with explicit async and fix the codegen to satisfy it

* Check implementers are registered in schema and vice versa

* Check argument camelCases

* Test argument defaults, and allow Into coercions for them

* Re-enable markers

* Re-enable markers and relax Sized requirement on IsInputType/IsOutputType marker traits

* Revert 'juniper_actix' fmt

* Fix missing marks for object

* Fix subscriptions marks

* Deduce result type correctly via traits

* Final fixes

* Fmt

* Restore marks checking

* Support custom ScalarValue

* Cover deprecations with tests

* Impl dowcasting via methods

* Impl dowcasting via external functions

* Support custom context, vol. 1

* Support custom context, vol. 2

* Cover fallible field with test

* Impl explicit generic ScalarValue, vol.1

* Impl explicit generic ScalarValue, vol.2

* Allow passing executor into methods

* Generating enum, vol.1

* Generating enum, vol.2

* Generating enum, vol.3

* Generating enum, vol.3

* Generating enum, vol.4

* Generating enum, vol.5

* Generating enum, vol.6

* Generating enum, vol.7

* Generating enum, vol.8

* Refactor juniper stuff

* Fix juniper tests, vol.1

* Fix juniper tests, vol.2

* Polish 'juniper' crate changes, vol.1

* Polish 'juniper' crate changes, vol.2

* Remove redundant stuf

* Polishing 'juniper_codegen', vol.1

* Polishing 'juniper_codegen', vol.2

* Polishing 'juniper_codegen', vol.3

* Polishing 'juniper_codegen', vol.4

* Polishing 'juniper_codegen', vol.5

* Polishing 'juniper_codegen', vol.6

* Polishing 'juniper_codegen', vol.7

* Polishing 'juniper_codegen', vol.8

* Polishing 'juniper_codegen', vol.9

* Fix other crates tests and make Clippy happier

* Fix examples

* Add codegen failure tests, vol. 1

* Add codegen failure tests, vol. 2

* Add codegen failure tests, vol.3

* Fix codegen failure tests accordingly to latest nightly Rust

* Fix codegen when interface has no implementers

* Fix warnings in book tests

* Describing new interfaces in Book, vol.1

Co-authored-by: Christian Legnitto <LegNeato@users.noreply.github.com>
2020-10-05 21:21:01 -10:00
Kai Ren
a684e1d91c
Re-enable marks-based static checks in code generated by macros (#751)
- add associated type to IntoResolvable and IntoFieldResult traits allowing to name the GraphQLType being resolved
- relax Sized requirement on some IsInputType and IsOutputType impls
2020-09-02 22:48:54 +03:00
Caio
2ab00f55d6
Remove unused dependencies (#747) 2020-08-28 20:34:11 -10:00
Christian Legnitto
59419f1ec4
Remove boxed in favor of pin. (#725) 2020-07-28 19:10:15 -10:00
Chris
f5839c034e
Fix subscriptions with custom scalars (#706) 2020-07-17 10:52:16 +03:00
Christian Legnitto
87883876bc
Fix some clippy issues (#704) 2020-07-16 07:41:09 -10:00
Kai Ren
4d77a1a9b9
Strip redundant Send/Sync bounds (#688)
Additionally:
- strip redundant type parameters for juniper::Context in some core definitions and reuse associated type
2020-06-30 18:13:15 +03:00
Kai Ren
7578175baf
Remove internal versions of proc macros (#687)
- generate always `::juniper::` crate path in proc macros and use `extern crate self` to make it work inside `juniper`
- add optional non-documented `internal` proc macro argument to proc macros, which allows double-underscored names and is used inside `juniper` only
2020-06-30 12:26:48 +03:00
Kai Ren
35b804c37b
Decouple object safe part from GraphQLType traits (#685)
- 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
2020-06-30 11:20:21 +03:00
Alexander Lyon
714d602fb9
Update to_camel_case to respect the rust convention of prefixing '_' for unused vars (#684) 2020-06-27 20:15:19 -10:00
Chris
6dd6abbadc
Fix custom ScalarValue usage for unions (#681)
- make GraphQLUnion trait generic over ScalarValue
- generate generic over ScalarValue impls of GraphQLUnion trait
- add codegen tests with a custom ScalarValue for union macros
2020-06-14 14:12:53 +03:00
tyranron
5b7706e839
Fix codegen failure tests for the latest nightly Rust 2020-06-10 11:36:36 +03:00
Kai Ren
ddc1488195
Codegen reimplementation for GraphQL unions (#666)
- 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
2020-06-04 11:19:01 +03:00
Jonas Meurer
558eae91df
Ensure Specification(June 2018) Compliance (#631)
* 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>
2020-05-01 16:24:01 -10:00
André Isaksson Kraft
2ba9f71b0c
Make graphql_scalar a proc macro (#610)
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>
2020-04-20 10:15:09 -10:00
Jonas Meurer
fe99e1cc70
Allow specifying scalar and context for GraphQLEnum (#621)
* 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
2020-04-17 19:09:04 -10:00
Jonas Meurer
a05f4e55c4
Derive macro for tagged enums (GraphQLUnion) (#618)
* 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>
2020-04-14 21:58:45 -10:00
Christian Legnitto
adc8d7be2d
Fix some clippy warnings (#595) 2020-03-31 08:34:50 -07:00
Gero Posmyk-Leinemann
5f777e8a6d
Clippy cleanup (#579) 2020-03-20 09:11:06 -07:00
nWacky
eb941e509a
Add subscription support (#433)
Co-authored-by: tyranron <tyranron@gmail.com>
Co-authored-by: Christian Legnitto <LegNeato@users.noreply.github.com>
2020-03-18 20:31:36 -07:00
Christian Legnitto
27e00419b0
More clippy and warnings. (#568)
Also, remove `dbg!()`
2020-03-14 08:55:06 -07:00
Christian Legnitto
2796d8df9a
More clippy fixes (#565) 2020-03-13 23:02:43 -07:00
Christian Legnitto
3b5cf4ad64
Fix some clippy lints (#564)
* Fix some clippy lints
2020-03-13 22:03:36 -07:00
Christian Legnitto
00b111a1ff
Remove async feature gate (#554)
This still has the async / non-async split. Future diffs will get
rid of `GraphQLTypeAsync` and move everything into `GraphQLType`.
2020-03-08 23:20:11 -07:00
Christian Legnitto
b63a44e0f8
Add futures dependency (#541)
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.
2020-02-20 21:53:39 -07:00
Christian Legnitto
7ee67ed6e8
Convert graphql_object to central util parsing (#526) 2020-02-12 23:46:59 -07:00
tyranron
c51c675306
Use caret requirement for specifying 'futures' crate version 2020-02-04 09:57:47 +01:00
Christian Legnitto
c42c71b02d Update to latest tokio 2020-01-22 07:56:03 -08:00
Christian Legnitto
80ef24fc12 Break dep cycle again 2020-01-21 07:53:36 -08:00
Christian Legnitto
98caeefbc0 Break dep cycle with features 2020-01-21 00:02:26 -08:00
Christian Legnitto
c6becfe234 Fix juniper_codegen tests under async 2020-01-20 23:38:44 -08:00
Christian Legnitto
7681f42933 Merge remote-tracking branch 'upstream/master' into async-await 2020-01-20 22:47:05 -08:00
Christian Legnitto
73dc5cd5b8 Release juniper 0.14.2 2020-01-18 17:14:35 -08:00
Christian Legnitto
a5ccf8c2a1 Release juniper_codegen 0.14.2 2020-01-18 17:14:35 -08:00
danieleades
6fa6c20fa7 address clippy::all lints (#486) 2019-12-17 20:37:46 -08:00
Christian Legnitto
eddf948dad Release juniper 0.14.2 2019-12-16 21:53:51 -08:00
Christian Legnitto
e4cfc4b09f Release juniper_codegen 0.14.2 2019-12-16 21:52:50 -08:00
Christoph Herzog
ce3cf45ca9 Rename object proc macro to graphql_object 2019-11-16 02:57:48 +01:00
Christoph Herzog
358071bfa4 Remove deprecated ScalarValue derive
This was renamed to GraphQLScalarValue and has been deprecated for a
while
2019-11-16 02:33:20 +01:00
Christoph Herzog
9ce3d04007 Improve union proc macro
* Rename to graphql_union
* Implement full-featured parsing and code generation
2019-11-16 02:33:18 +01:00
Christoph Herzog
5d270b7dea Formatting 2019-11-15 22:18:38 +01:00
Christoph Herzog
50605ee73e Duplicate juniper_rocket for async
This is required because rocket only supports futures on a git branch.
2019-11-15 21:52:22 +01:00
Christoph Herzog
f6c0bc7b02 Fix tests. 2019-11-15 21:44:08 +01:00
Christoph Herzog
b634ad39eb Various async feature fixes for the type system 2019-11-15 21:23:59 +01:00
Christoph Herzog
ad16093b88 Refactor GraphQLType::resolve to return Result<>
This unifies the output type of all resolvers.

Required for future step of making the output a associated type.
2019-11-14 09:51:32 +01:00
Christoph Herzog
36c71d7162 chore: Remove ScalarRefValue trait
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.
2019-11-14 01:21:41 +01:00
nWacky
eb85fefc36 Get back panic in macro [skip ci] 2019-11-13 14:26:25 +00:00
nWacky
2144ad0d7d Remove async-trait [skip ci] 2019-11-13 14:26:25 +00:00
nWacky
cf99495368 Replace all futures::BoxFuture with juniper::BoxFuture 2019-11-12 12:04:09 +00:00
nWacky
237e69c036 Rebase async_await onto master (#454)
* 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]
2019-11-08 09:46:48 +00:00
David Pedersen
1148c75a1d 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 {}
}
```
2019-11-06 23:08:25 +00:00
nWacky
778606c050
Fix bad merge [skip ci] 2019-11-06 12:01:50 +03:00
nWacky
99c0d26887
Comment out attr_arg_descr and attr_arg_descr_collapse tests 2019-11-05 12:06:08 +03:00
nWacky
dbcaf30ec3
Rebase onto master 2019-11-05 11:20:06 +03:00
nWacky
e3c12e31fc
Format 2019-11-05 11:14:53 +03:00
nWacky
00dd1dc391
Resolve better error message with field/type name todo, update other panics with query name 2019-11-05 11:14:20 +03:00
nWacky
52c3e281f3
Refactor GraphQLTypeAsync to use async-trait 2019-11-05 11:14:20 +03:00
Christian Legnitto
191468bf04
Release juniper 0.14.1 2019-11-05 11:14:16 +03:00
Christian Legnitto
7b18bd245d
Release juniper_codegen 0.14.1 2019-11-05 11:14:15 +03:00
Christian Legnitto
0929bad163 Fix non-async resolvers with returns in the async case 2019-11-03 22:14:44 -08:00
Christian Legnitto
560a172587 Make resolvers with returns work again
Note that this only fixes the non-async case
2019-11-03 22:07:40 -08:00
nWacky
321c3af38d Use name_of_type in macro [skip ci] 2019-11-01 12:59:16 +00:00
nWacky
245c351a73 Revert juniper::object name detection back to master [skip ci] 2019-11-01 12:59:16 +00:00
Christoph Herzog
ee9a82a817 Refacto graphql_union! macro to proc macro 2019-10-28 21:51:29 +01:00
Christian Legnitto
c434bddc91 Release juniper 0.14.1 2019-10-24 15:57:16 -07:00
Christian Legnitto
252f7b4353 Release juniper_codegen 0.14.1 2019-10-24 15:56:44 -07:00
tyranron
e2903cf0f7
Fix type inferring for trivial resolver code
Additionally:
- fix inconsistencies after merge with master
2019-10-10 14:50:10 +02:00
tyranron
635bf1ff34
Merge branch 'async-await' into remove-async-closure-feature
# Conflicts:
#	examples/warp_async/src/main.rs
#	integration_tests/async_await/src/main.rs
#	juniper/src/lib.rs
#	juniper_benchmarks/src/lib.rs
#	juniper_rocket/src/lib.rs
#	juniper_warp/src/lib.rs
2019-10-10 13:20:00 +02:00
Christoph Herzog
56a4f2558a WIP async/await implementation 2019-10-09 22:22:13 -07:00
tyranron
5d3ed9ac72
Remove async_closure feature usage 2019-10-10 00:07:10 +02:00
Christian Legnitto
dbbceae643 Release juniper 0.14.0 2019-09-29 19:04:31 -07:00
Christian Legnitto
c4d7661b3b Release juniper_codegen 0.14.0 2019-09-29 19:03:54 -07:00
Blaž Hrastnik
dcbb74155d juniper_codegen: Drop regex & lazy_static dependencies (#424)
* Replace regex & lazy_static with a simple check.
2019-09-07 21:19:37 -07:00
Christoph Herzog
a14f0ddebd WIP async/await implementation 2019-08-21 15:48:31 +02:00
theduke
a3caf126b0 derive: Upgrade syn/quote/proc_macro dependencies to 1.0 (#413) 2019-08-18 09:12:25 -07:00
Christian Legnitto
48c26a26b3 Release juniper 0.13.1 2019-07-29 08:08:05 -07:00
Christian Legnitto
6b32e90899 Release juniper_codegen 0.13.2 2019-07-29 08:07:32 -07:00
Christian Legnitto
644d6042ae Release juniper_codegen 0.13.1 2019-07-29 08:06:22 -07:00
Christoph Herzog
049ba0c9dc (codegen) Respect mut modifier on arguments in object proc macro
This commit forwards `mut` declaration of arguments in a #[juniper::object] macro invocation
to the generated code.

Closes #399
2019-07-24 02:37:31 +02:00
Christian Legnitto
54f98f46db Release juniper 0.13.0 2019-07-19 14:01:21 -07:00