Commit graph

563 commits

Author SHA1 Message Date
ArsileLuci
dc99ae70b8
Fix fields on interface not being resolved when used with fragments (#923, #922) 2021-04-30 15:13:54 +03:00
tyranron
106e322f68
Catch up codegen failure tests with latest nightly Rust 2021-04-29 14:06:32 +03:00
Christian Legnitto
9576c25fe7
Fix markdown in changelog 2021-04-18 22:14:50 -10:00
Tilman Roeder
5ae930bfc7
Fixes Issue 914 (#915)
* Add failing tests

* Fix failing test

* cargo fmt
2021-04-17 13:29:08 -10:00
Christian Legnitto
97d8b70ea0 Release juniper 0.15.4 2021-04-03 15:36:50 -10:00
Christian Legnitto
1815d23194 Release juniper_codegen 0.15.4 2021-04-03 15:35:33 -10:00
Christian Legnitto
ed3bb68329
Add min so newer cargo-release doesn't fail (#909) 2021-04-03 15:13:25 -10:00
Jerel Unruh
c78045c167
Make the executor and validation APIs public to enable split parsing and execution (#874)
* Make the executor and validation APIs public to enable splitting parsing and execution into two stages

Based on https://github.com/graphql-rust/juniper/pull/773#issuecomment-703783048 and https://github.com/graphql-rust/juniper/pull/773#issuecomment-704009918

* Fix fmt warning for visit_all_rules

* Add `Definition` to the public API so it's available for the result of compilation

* Make OperationType public so that user land code can tell the difference between query/mutation and subscription

* Add integrations tests for execute_validated_query_async, visit_all_rules, get_operation, and resolve_validated_subscription

Co-authored-by: Christian Legnitto <LegNeato@users.noreply.github.com>
2021-04-02 19:13:06 -10:00
Tilman Roeder
e7f7e7bff3
Fragment spreads in Interface types (#907)
* Add failing test

* Fix fragment spread on interface

* Cargo fmt

* Add test and fix for sync version

* Cargo fmt
2021-04-02 09:34:52 -10:00
Edward Rudd
09637fba94
Un-deprecate the select_child, has_child, and child_names methods (#900)
- Issues with removing them documented in issue #878

Co-authored-by: Christian Legnitto <LegNeato@users.noreply.github.com>
2021-03-29 23:12:48 -10:00
André Isaksson Kraft
0de631741e
Use smartstring for name of field (#819). (#899)
Co-authored-by: Christian Legnitto <LegNeato@users.noreply.github.com>
2021-03-29 19:29:08 -10:00
dependabot-preview[bot]
61fbd6ef7f
Update pretty_assertions requirement from 0.6.1 to 0.7.1 (#895)
Updates the requirements on [pretty_assertions](https://github.com/colin-kiegel/rust-pretty-assertions) to permit the latest version.
- [Release notes](https://github.com/colin-kiegel/rust-pretty-assertions/releases)
- [Changelog](https://github.com/colin-kiegel/rust-pretty-assertions/blob/main/CHANGELOG.md)
- [Commits](https://github.com/colin-kiegel/rust-pretty-assertions/compare/v0.6.1...v0.7.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-03-29 18:23:33 -10:00
Alex Touchet
06b1fbce0c
Update iron link (#890) 2021-03-01 17:26:44 -10:00
abrackx
f5ce9f2d79
Switch to HashMap for the internal representation of object fields (#872)
* Resolves #818. Updates Object key_value_list to use HashMap<String, Value<S>>. Updates test cases.

* Updates to use IndexMap. Reverts changes to test cases.

Co-authored-by: Christian Legnitto <LegNeato@users.noreply.github.com>
2021-02-28 18:10:53 -10:00
trevyn
d5458f4979
Fix CI (#884)
* fix some CI errors

* Remove `-C link-dead-code` in tests

Seems to break things on Windows.
2021-02-26 10:27:16 -10:00
wangcong
3b6c3f9c0f
Fix typo (#866)
Co-authored-by: Christian Legnitto <LegNeato@users.noreply.github.com>
2021-01-27 23:46:20 -10:00
Christian Legnitto
212f896e40 Release juniper 0.15.3 2021-01-27 17:54:00 -10:00
Christian Legnitto
fc1c7dfe63 Release juniper_codegen 0.15.3 2021-01-27 17:53:14 -10:00
Christian Legnitto
dc902d7296
Update CHANGELOG.md 2021-01-27 04:25:08 -10:00
Matt Wilkinson
2c9c172252
Use working GraphQL Playground version (#856)
* Use working GraphQL Playground version

the linked file on jsDelivr doesn't work, as I detailed in this issue on the GraphQL Playground repo (https://github.com/graphql/graphql-playground/issues/1310). Going back to version 1.7.20 ensures the playground loads for now until they can publish a new version with a working middleware.js file.

* Add versions for css and favicon

* Update from 1.7.20 to 1.7.26

Using latest version that still works
2021-01-25 22:38:15 -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
329caad4cd
Update CHANGELOG.md 2021-01-15 19:41:27 -10:00
Christian Legnitto
2e24b55e99 Update GraphQL Playground
Version taken from https://www.jsdelivr.com/package/npm/graphql-playground-react.

Fixes https://github.com/graphql-rust/juniper/issues/830
2021-01-15 19:36:29 -10:00
Kai Ren
4682fe2f4e
Add missing marker trait impls for container types (#847) 2021-01-15 07:31:50 -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
851918ec77
Update CHANGELOG.md 2020-12-12 09:44:00 -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
Graeme Coupar
fe86dbb782
Mark Arc with IsInputType & IsOutputType. (#822)
* 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>
2020-12-11 16:30:41 -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
Lukas Kalbertodt
2c15ea798c
Check type before resolving in inline fragments to fix panic when using inline fragments with interfaces (#816, #815) 2020-12-09 20:26:59 +02: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
tyranron
8783496c68
Mention an example of migration from graphql-interface! to #[graphql_interface] in README 2020-11-14 14:48:53 +01: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
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
Lucas Pickering
200896053a
Fix #500 (crash from look_ahead on nested fragments) (#800) 2020-11-04 15:11:25 -08:00
David Pedersen
eca049ac28
Implement IntoFieldError for Infallible (#796)
Makes it possible to use `Result<T, Infallible>` as your return type
from resolvers, which can be handy sometimes.
2020-10-29 06:39:59 -07:00
Christian Legnitto
f6ec735ba9
Uncomment tests that now work (#797)
* Uncomment tests that now work

* Fix formatting
2020-10-28 20:40:35 -07: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
Stijn Frishert
68210f54ca
impl Display for ID (#783) 2020-10-10 07:17:33 -07:00
Kai Ren
46cde4fb85
Fix parsing f64 from Scalar::Int (#777) 2020-10-07 14:40:36 -10:00
tyranron
f914322ef4
Mention #[graphql_interface] macro in CHANGELOG (#682) 2020-10-07 10:20:11 +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
dac4e648c1
Fix LookAheadMethods lifetimes (#757) 2020-09-10 12:00:58 -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
Mihai Dinculescu
45c16acc6e
Actix subscriptions tests (#736)
* Actix subscriptions tests

* Use LocalBoxFuture instead of async-trait

* expose-test-schema already includes serde_json

* Add anyhow to juniper dev-dependencies

* The HTTP test helpers are not needed for juniper tests

* juniper_actix does not need tokio in dev-dependencies

Co-authored-by: Christian Legnitto <LegNeato@users.noreply.github.com>
2020-08-18 21:08:53 -10:00
Mihai Dinculescu
8d7ba8295c
Impl subscriptions for juniper_actix (#716)
* Impl subscriptions for juniper_actix

* Add random_human example subscription

* Add actix_subscriptions example to CI

* fixup! Add random_human example subscription

* Migrate actix subscriptions to juniper_graphql_ws

* Simplify error handling

* Change unwrap to expect

* Close connection on server serialization error

Co-authored-by: Christian Legnitto <LegNeato@users.noreply.github.com>
2020-08-09 12:19:34 -10:00
Chris
84c9720b53
GraphQL-WS crate and Warp subscriptions update (#721)
* update pre-existing juniper_warp::subscriptions

* initial draft

* finish up, update example

* polish + timing test

* fix pre-existing bug

* rebase updates

* address comments

* add release.toml

* makefile and initial changelog

* add new Cargo.toml to juniper/release.toml
2020-07-28 22:23:44 -10:00
Chris
dc309b83b7
Simplify SubscriptionConnection (#719)
* simplify SubscriptionConnection

* fmt

* update pre-existing juniper_warp::subscriptions

* use struct instead of tuple

* fmt

* update juniper_warp
2020-07-28 19:14:53 -10:00
Christian Legnitto
59419f1ec4
Remove boxed in favor of pin. (#725) 2020-07-28 19:10:15 -10:00
Christian Legnitto
29930b002b
Update compile fail tests for nightly Rust (#710)
* 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
2020-07-18 13:19:50 -10:00
Christian Legnitto
87883876bc
Fix some clippy issues (#704) 2020-07-16 07:41:09 -10:00
Christian Legnitto
3c79f6a2c5
Move starwars schema into fixture directory (#694)
Move starwars query into fixture directory

Also include the graphql schema definition file and a test
to make sure they match.
2020-07-15 21:46:37 -10:00
Christian Legnitto
61cb75969e
Move and enable public api integration tests (#692) 2020-07-08 16:40:34 -10:00
Christian Legnitto
de3a79a142
Update CHANGELOG.md 2020-07-05 19:54:08 -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
Christian Legnitto
ed6b257e58
Small typo changes to CHANGELOG 2020-06-27 23:52:28 -10:00
Christian Legnitto
c7cc1daed2
Update CHANGELOG.md 2020-06-27 21:41:24 -10:00
Christian Legnitto
03844468f7
Fix minor CHANGELOG typos 2020-06-27 21:38:19 -10:00
Christian Legnitto
54860880d9
Reword changelog 2020-06-27 21:34:54 -10: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
Kai Ren
5b9c6111f1
Relax redundant 'static lifetime bounds on ScalarValue in juniper_subscriptions::Coordinator (#680) 2020-06-10 21:27:58 -10:00
Nathan Wilson
7365b0fdd8
Upgrade bson crate to 1.0 (#678) 2020-06-10 12:34:56 +03:00
Christian Legnitto
9167654a73
Add support for GraphQL Schema Language (#676)
Co-authored-by: Alexander Lyon <arlyon@me.com>
2020-06-05 17:43:11 -10:00
Jordão Rodrigues Oliveira Rosario
40ad17c540
Normalize subscriptions endpoint in graphiql_source (#628)
The objective here is to make the Playground and GraphiQL have the same behavior with the endpoint arguments.
2020-06-05 00:45:19 +03:00
Nathan Wilson
5cf21bf41b
Fix PR #662's entry in CHANGELOG pointed to incorrect link (#675) 2020-06-04 23:46:14 +03:00
Nathan Wilson
02801ee981
Upgrade bson crate to 0.15.0 (#674) 2020-06-04 23:40:06 +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
Teymour Aldridge
31d08888e4
Make some comments clearer. (#665) 2020-05-23 20:29:58 -10:00
Caio
2cb96d0fc4
impl GraphQLScalar for NaiveTime (#657)
* impl GraphQLScalar for NaiveTime

* Add feature
2020-05-20 22:13:31 -10:00
Caio
0bb1c5beac
Relax Default impl constraint (#664)
* Relax Default impl constraint

For EmptyMutation and EmptySubscription. The built-in derive
expects `T: Default`, which is not necessary for a PhantomData
wrapper.

* Add test
2020-05-19 05:46:56 -10:00
bumblepie
5021ae80e1
Improve lookahead visibility for aliased fields (#662)
* Improve lookahead visibility for aliased fields
- Add a method to access the children of look ahead structs
- Make the behaviour around accessing aliased lookahead fields more consistent

* Deprecate old Lookahead methods for accessing child selections
2020-05-16 21:43:37 -10:00
Kai Ren
aedb2d1eb4
Support "Content-Type: application/graphql" (#426) (#654)
* Support 'application/graphql' POST requests for 'juniper_warp'

* Add integration tests for 'application/graphql' POST requests and revive HttpIntegration test suite for 'juniper_warp'

* Support 'application/graphql' POST requests for 'juniper_hyper' and run its tests for both sync and async versions

* Run integration tests for both sync and async versions of 'juniper_warp' and update its CHANGELOG

* Support 'application/graphql' POST requests for 'juniper_iron'

* Fix 'application/graphql' POST requests support for 'juniper_actix'

* Support 'application/graphql' POST requests in 'juniper_rocket' and 'juniper_rocket_async'

* Upd juniper's CHANGELOG
2020-05-08 06:00:49 -10: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
Christian Legnitto
358ca27d28
Fix panic with invalid unicode query (#645)
Without this fix the panic looks like the following:

```rust
---- parser::tests::lexer::string_errors stdout ----
thread 'parser::tests::lexer::string_errors' panicked at 'byte index 4 is not a char boundary; it is inside 'ɠ' (bytes 3..5) of `"\uɠ^A`', src/libcore/str/mod.rs:2219:5
```

This was found via fuzzing with `cargo-fuzz`.
2020-04-30 16:08:23 -10:00
Kai Ren
52aea4d68d
Disallow deserialize empty GraphQLBatchRequest (#639) (#644)
* Disallow deserialize empty GraphQLBatchRequest (#639)

* Add test for empty batch request
2020-04-30 06:16:15 -10:00
Kai Ren
79c265f027
Remove direct usage of 'serde_derive' crate and redundant usage of 'serde' crate (#640) 2020-04-28 06:39:35 -10:00
Byeongjee Kang
c761d91c69
Fix a minor typo in comment (#637) 2020-04-27 18:09:00 -10:00
Kai Ren
9064d7f523
Avoid unnecessary Vec allocation when executing GraphQLBatchRequest (#638)
Additionally:
- make GraphQLBatchRequest/GraphQLBatchResponse code a bit more laconic
2020-04-27 18:08:27 -10:00
Byeongjee Kang
dc4cdf0bf5
Fix deprecated comments (#635)
build_*_type methods return meta types directly.
They don't return builders.
2020-04-26 20:28:05 -10:00
Jordão Rodrigues Oliveira Rosario
a47d1c5430
Add actix-web integration (#603) 2020-04-20 20:21:02 -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
Matthew Kuo
47f7ffaa5b
Add subscriptions support for GraphiQL (#619)
* Add subscriptions support on GraphiQL

Addresses #501

BREAKING CHANGE: `juniper::http::graphiql::graphiql_source` now requires
a second parameter

BREAKING CHANGE: `juniper_hyper::graphiql` now requires
a second parameter

BREAKING CHANGE: `juniper_iron::GraphiQLHandler::new` now requires
a second parameter

BREAKING CHANGE: `juniper_rocket::graphiql_source` now requires
a second parameter

BREAKING CHANGE: `juniper_warp::graphiql_filter` now requires
a second parameter

* Add test where graphiql subscriptions endpoint is not None
2020-04-12 15:03:09 -10:00
Christian Legnitto
5f454e05c7
Move graphiql export location (#615)
This fixes a TODO.
2020-04-10 00:06:39 -10:00
Christian Legnitto
2618100140
Update juniper_rocket to central GraphQLBatch* enums (#614) 2020-04-09 23:24:33 -10:00
Christian Legnitto
c09be69b7d
Update rocket_async to central GraphQLBatch* enums (#612) 2020-04-09 22:10:24 -10:00
Jordão Rodrigues Oliveira Rosario
926d4e5738
Changed implementation location for GraphQLBatchRequest/Response (#608) 2020-04-09 19:35:30 -10:00
Jordão Rodrigues Oliveira Rosario
1412561ffd
Added document validation in the resolve_into_stream method and a test (#604) 2020-04-05 11:59:10 -10:00
Aaron Housh
e5f655044e
Add debug derive to GraphQLResponse (#599) 2020-04-04 17:27:11 -10:00
Christian Legnitto
adc8d7be2d
Fix some clippy warnings (#595) 2020-03-31 08:34:50 -07:00
Samuel Hurel
6e4bc127b0
Add support for bson::UtcDateTime (#585) 2020-03-24 17:21:05 -07:00
Jade Devin Cabatlao
cab6decdbc
Implement GraphQLTypeAsync for Box (#582) 2020-03-21 22:04:58 -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
Jade Devin Cabatlao
b7cc424bff
Expose SchemaType (#569)
Executor.schema(&self) is kind of useless without declaring SchemaType as public
2020-03-17 22:28:40 -07:00
Christian Legnitto
27e00419b0
More clippy and warnings. (#568)
Also, remove `dbg!()`
2020-03-14 08:55:06 -07:00
Christian Legnitto
f247dbee48
Fix most warnings (#567) 2020-03-14 00:01:02 -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
Tommaso Checchi
fd4290462c
Require serde_json when enabling expose-test-schema (#527)
I noticed that `juniper` fails to build if the `"expose-test-schema"` feature is enabled without also enabling `"serde_json"`. I guess it might make sense to add it as a dependency so people don't have to check this file to figure that out!

Co-authored-by: Christian Legnitto <LegNeato@users.noreply.github.com>
2020-03-13 21:38:10 -07:00
Christian Legnitto
bc7e5bac13
Add docs to silence warnings for async (#563) 2020-03-13 19:34:22 -07:00
Christian Legnitto
48c924ea27
Async tests (#559)
Convert more tests to async
2020-03-10 19:11:40 -07:00
Christian Legnitto
961a07125f
Convert more tests to async (#558) 2020-03-10 00:12:09 -07:00
Christian Legnitto
bdaa77053d
Fix field_execution and merge_parallel_inline_fragments tests under async (#557)
The ordering was off when run under async. Not 100% sure I understand this code but this seems
to work.
2020-03-09 23:40:54 -07:00
Christian Legnitto
e9b8aa2c38
Rename execute -> execute_sync, execute_async -> execute (#556) 2020-03-09 22:40:26 -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
David Pedersen
ca28e90f7e
Implement std::error::Error for all error types (#419)
* Implement `std::error::Error` for all error types

* Fix copy-paste

* Implement `Display` for `Value`

This is required for implementing `Display` for `FieldError`

* Implement `std::error::Error` for `FieldError`

This required removing `impl From<T> for FieldError where T: Display`
because it would otherwise cause a conflicting implementation. That is
because `impl From<T> for T` already exists.

Instead I added `impl From<String> for FieldError` and `impl From<&str>
for FieldError` which should cover most use cases of the previous
  `impl`. I also added `FieldError::from_error` so users can convert
  from any error they may have.

* Bring back `impl<T: Display, S> From<T> for FieldError<S>`

We cannot have this and `impl<S> std::error::Error for FieldError<S>` so
we agreed this is more valuable. More context https://github.com/graphql-rust/juniper/pull/419

* Write errors without allocations
2020-02-20 22:31:58 -07:00
Nathan Wilson
389fd5ca19
Add bson crate's ObjectId to juniper foreign scalar type integrations (#517) 2020-02-12 23:49:50 -07:00
Jordão
75b597d8f3 Added usage of context validator in the async executor 2020-02-05 18:10:43 -08:00
tyranron
c51c675306
Use caret requirement for specifying 'futures' crate version 2020-02-04 09:57:47 +01:00
tyranron
dd9c201352 Upgrade uuid to 0.8 version 2020-01-29 01:59:42 -05:00
Christian Legnitto
c984457e91 Fix scalar and some tests under async
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.
2020-01-27 23:41:38 -05:00
Christian Legnitto
c42c71b02d Update to latest tokio 2020-01-22 07:56:03 -08:00
Christian Legnitto
e97d25d650 Fix formatting 2020-01-20 23:29:29 -08:00
Christian Legnitto
7681f42933 Merge remote-tracking branch 'upstream/master' into async-await 2020-01-20 22:47:05 -08:00
iancormac84
001cabc9e9 Changes. 2020-01-18 17:14:35 -08:00
iancormac84
c6ac0bdcef Add changes from async-await branch to Changelog. 2020-01-18 17:14:35 -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
Christian Legnitto
3c41769cb7 Update quickstart on every release (#485) 2020-01-18 17:14:35 -08:00
Massimo Cairo
9fe1c29889 Validate variables of the executed operation only (#462)
* Validate variables of the executed operation only

* Use `unreachable!` in `validate_var_defs`.

Use `unreachable!` instead of `panic!` on invalid variable types,
since thay have already been checked during document validation.

* Fix formatting in `validation/input_value.rs`
2020-01-18 17:14:35 -08:00
Alexander Simmerl
16967d7d98 Add example of how to construct null in graphql_value 2020-01-18 17:14:35 -08:00
Massimo Cairo
d4c75f0ba5 Fix unused variable error message
Was copied from undefined variable error message.
2020-01-18 17:14:35 -08:00
Jens Krause
14986ff419 Use latest graphiql (v0.17.2) (#477)
incl. upgrade to latest React
2020-01-18 17:14:35 -08:00
Jens Krause
c342ecf73a Use latest graphql-playground (#476) 2020-01-18 17:14:35 -08:00
James Harton
bc9183784f Loosen constraints on uuid version.
The `uuid` maintainers have started releasing in the `0.8` version train.  I've relaxed the version requirements on `juniper`'s dependencies to allow juniper users to specify a different version in their `Cargo.toml` and still have the integration work.
2020-01-18 17:14:35 -08:00
Corey Farwell
758c7967d4 Bump to latest graphiql (#489)
https://github.com/graphql/graphiql/releases
2020-01-07 22:19:29 -08:00
Graeme Coupar
c2f0dd2aec Implement GraphQLTypeAsync for Arc (#479)
* Implement GraphQLTypeAsync for Arc

I'm building a GraphQL API using Juniper that proxies another GraphQL
API.  It does a large fetch upfront from the underlying GraphQL API,
transforms it into a different format and then implements some
resolvers that do some further filtering.

One of these resolvers ends up looking like:

```
async fn items(&self, ...) -> Vec<Item> {
    self.items.iter().filter(...).collect()
}
```

This causes us problems as we're returning owned Item's and Item is a
large nested structure that would be expensive to clone.

Our current work around was to put Item into an Arc, as Arc is
comparatively cheap to clone.  So our method becomes:

```
async fn items(&self, ...) -> Vec<Arc<Item>> {
    self.items.iter().filter(...).map(Arc::clone).collect()
}
```

However to support this we needed Arc to implement GraphQLTypeAsync.
This commit adds that support to juniper, by forwarding to the
GraphQLTypeAsync implementation for the contained type.

It's possible that we could have acheived something similar by adding
some lifetimes to our resolver and returning a reference, but using an
Arc was easier for us in this case.  I'm not sure if there's any reason
why this would be a bad addition to Juniper overall?

* Move GraphQLTypeAsync for Arc<T> into pointers.rs
2019-12-22 14:54:03 -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
Christian Legnitto
cd0142ff52
Update quickstart on every release (#485) 2019-12-16 21:47:48 -08:00
Massimo Cairo
675ae060f3 Validate variables of the executed operation only (#462)
* Validate variables of the executed operation only

* Use `unreachable!` in `validate_var_defs`.

Use `unreachable!` instead of `panic!` on invalid variable types,
since thay have already been checked during document validation.

* Fix formatting in `validation/input_value.rs`
2019-12-16 00:17:13 -08:00
Alexander Simmerl
26bfe7652f
Add example of how to construct null in graphql_value 2019-12-15 13:31:24 +01:00
David Pedersen
3a6d5e6a46
Merge pull request #481 from cairomassimo/fix-unused-variable-error-message
Small fix/typo: unused variable error message
2019-12-11 18:00:38 +01:00
Massimo Cairo
8f1bf8c661 Fix unused variable error message
Was copied from undefined variable error message.
2019-12-11 17:27:06 +01:00
Jens Krause
93f3dc3d72 Use latest graphiql (v0.17.2) (#477)
incl. upgrade to latest React
2019-12-09 10:36:09 -08:00
Jens Krause
38ee6edb9e Use latest graphql-playground (#476) 2019-12-09 10:34:31 -08:00
James Harton
5d56c9f221 Loosen constraints on uuid version.
The `uuid` maintainers have started releasing in the `0.8` version train.  I've relaxed the version requirements on `juniper`'s dependencies to allow juniper users to specify a different version in their `Cargo.toml` and still have the integration work.
2019-12-01 14:27:41 +01:00
Christoph Herzog
ce3cf45ca9 Rename object proc macro to graphql_object 2019-11-16 02:57:48 +01:00
Christoph Herzog
a31d3f3888 Remove old graphql_object! macro 2019-11-16 02:33:20 +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
6861951a1e Disable async tests for juniper 2019-11-15 22:36:25 +01:00
Christoph Herzog
27e5e447c7 Fix pattern move error on stable 2019-11-15 22:34:08 +01:00
Christoph Herzog
641e87a0b6 Add back documentation for graphql_scalar! macro 2019-11-15 22:18:39 +01:00
Christoph Herzog
4f287806bd Update CHANGELOG with master breaking changes 2019-11-15 22:18:39 +01:00
Christoph Herzog
5d270b7dea Formatting 2019-11-15 22:18:38 +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
6fcdd32c84 Remove GraphQLType ScalarValue default
This is more hinderance than useful.
2019-11-14 01:31:14 +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
2144ad0d7d Remove async-trait [skip ci] 2019-11-13 14:26:25 +00:00
nWacky
a5580a939d Update most crates to futures 0.3, add todos on not updated crates 2019-11-12 12:04:09 +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
e344f1c06f
Merge branch 'async-await-resolve-some-todos' of https://github.com/instrumentisto/juniper into async-await-resolve-some-todos
# Conflicts:
#	juniper/src/macros/tests/args.rs
[skip ci]
2019-11-06 11:46:21 +03:00
nWacky
09d9513da9
Rebase onto master 2019-11-06 11:45:19 +03:00
nWacky
4834349310
Rebase onto async-await 2019-11-06 11:21:06 +03:00
nWacky
e151026cfa
Merge branch 'async-await-resolve-some-todos' of https://github.com/instrumentisto/juniper into async-await-resolve-some-todos
# Conflicts:
#	examples/warp_async/Cargo.toml
#	juniper/src/macros/tests/args.rs
#	juniper_codegen/src/util.rs
[skip ci]
2019-11-05 12:10:04 +03:00
nWacky
99c0d26887
Comment out attr_arg_descr and attr_arg_descr_collapse tests 2019-11-05 12:06:08 +03:00
nWacky
7135c07ae5
Format 2019-11-05 11:20:08 +03:00
nWacky
9506272b82
Merge import in async_await 2019-11-05 11:20:07 +03:00
nWacky
554ba34df1
Format 2019-11-05 11:20:07 +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
b1970aecd2
Remove useless todo 2019-11-05 11:14:20 +03:00
nWacky
52c3e281f3
Refactor GraphQLTypeAsync to use async-trait 2019-11-05 11:14:20 +03:00
nWacky
820f472f2c
Add resolve_into_type_async 2019-11-05 11:14:19 +03:00
nWacky
e03e525645
Start adding async-trait to GraphQLTypeAsync 2019-11-05 11:14:19 +03:00
nWacky
bfe6c7ae97
Remove __juniper_extract_generic macro 2019-11-05 11:14:18 +03:00
nWacky
d22b5c68f3
Resolve RFC 2565 related todos 2019-11-05 11:14:18 +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
bb99076326
Update CHANGELOG.md 2019-11-05 11:14:15 +03:00
Christian Legnitto
665c3d2eb6
Make EmptyMutation Send 2019-11-05 11:14:15 +03:00
Christian Legnitto
7230efc3b9
Update CHANGELOG.md 2019-11-05 11:14:14 +03:00
Andrey Kutejko
779208eea5
Bubble up scalar error (#434) 2019-11-05 11:14:14 +03:00
nWacky
3e5e2aeeb7
Format 2019-11-04 19:13:06 +03:00
nWacky
e2ebaeec3a
Merge import in async_await 2019-11-04 19:11:12 +03:00
nWacky
503bb6357f
Format 2019-11-04 19:07:25 +03:00
nWacky
09d1077735
Merge branch 'async-await-resolve-some-todos' of https://github.com/instrumentisto/juniper into async-await-resolve-some-todos 2019-11-04 18:53:42 +03:00
nWacky
2404b81008
Rebase onto master 2019-11-04 18:52:26 +03:00
nWacky
afd92cd7fe
Format 2019-11-04 16:55:36 +03:00
nWacky
9478b6c590
Remove useless todo 2019-11-04 11:40:52 +03:00