Skip to content

Commit 6aed455

Browse files
committed
Prepare for 0.8.0 release
1 parent 39e1cba commit 6aed455

File tree

7 files changed

+107
-18
lines changed

7 files changed

+107
-18
lines changed

CHANGELOG.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,38 @@
11
Change log
22
==========
33

4+
## [0.8.0] – 2017-06-15
5+
6+
## Breaking changes
7+
8+
* To better comply with the specification, and to avoid weird bugs with very
9+
large positive or negative integers, support for `i64` has been completely
10+
dropped and replaced with `i32`. `i64` is no longer a valid GraphQL type in
11+
Juniper, and `InputValue`/`Value` can only represent 32 bit integers.
12+
13+
If an incoming integer is out of range for a 32 bit signed integer type, an
14+
error will be returned to the client.
15+
([#52](https://github.com/mhallin/juniper/issues/52),
16+
[#49](https://github.com/mhallin/juniper/issues/49))
17+
18+
* Serde has been updated to 1.0. If your application depends on an older
19+
version, you will need to first update your application before you can upgrade
20+
to a more recent Juniper. ([#43](https://github.com/mhallin/juniper/pull/43))
21+
22+
* `rustc_serialize` support has been dropped since this library is now
23+
deprecated. ([#51](https://github.com/mhallin/juniper/pull/51))
24+
25+
## New features
26+
27+
* A new `rocket-handlers` feature now includes some tools to use the
28+
[Rocket](https://rocket.rs) framework. [A simple
29+
example](examples/rocket-server.rs) has been added to the examples folder.
30+
31+
## Bugfixes
32+
33+
* A panic in the parser has been replaced with a proper error
34+
([#44](https://github.com/mhallin/juniper/pull/44))
35+
436
## [0.7.0] – 2017-02-26
537

638
### Breaking changes
@@ -293,7 +325,8 @@ using the macros and not deriving `GraphQLType` directly.
293325
* Macro syntax stability has also been improved. All syntactical edge
294326
cases of the macros have gotten tests to verify their correctness.
295327

296-
[0.6.3]: https://github.com/mhallin/juniper/compare/0.6.3...0.7.0
328+
[0.8.0]: https://github.com/mhallin/juniper/compare/0.7.0...0.8.0
329+
[0.7.0]: https://github.com/mhallin/juniper/compare/0.6.3...0.7.0
297330
[0.6.3]: https://github.com/mhallin/juniper/compare/0.6.2...0.6.3
298331
[0.6.2]: https://github.com/mhallin/juniper/compare/0.6.1...0.6.2
299332
[0.6.1]: https://github.com/mhallin/juniper/compare/0.6.0...0.6.1

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "juniper"
3-
version = "0.7.0"
3+
version = "0.8.0"
44
authors = ["Magnus Hallin <[email protected]>"]
55
description = "GraphQL server library"
66
license = "BSD-2-Clause"

README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ GraphQL servers in Rust that are type-safe and blazingly fast.
1313

1414
Juniper does not include a web server - instead it provides building blocks to
1515
make integration with existing servers straightforward. It optionally provides a
16-
pre-built integration for the [Iron framework][iron].
16+
pre-built integration for the [Iron][iron] and [Rocket] frameworks.
1717

1818
* [Cargo crate](https://crates.io/crates/juniper)
1919
* [API Documentation](http://mhallin.github.io/juniper)
@@ -24,15 +24,23 @@ Add Juniper to your Cargo.toml:
2424

2525
```toml
2626
[dependencies]
27-
juniper = "0.7.0"
27+
juniper = "0.8.0"
2828
```
2929

3030
If you want the Iron integration enabled, you need to enable the `iron-handlers`
3131
feature flag:
3232

3333
```toml
3434
[dependencies]
35-
juniper = { version = "0.7.0", features = ["iron-handlers"] }
35+
juniper = { version = "0.8.0", features = ["iron-handlers"] }
36+
```
37+
38+
If you want the Rocket integration enabled, you need to use the nightly Rust
39+
compiler and enable the `rocket-handlers` feature flag:
40+
41+
```toml
42+
[dependencies]
43+
juniper = { version = "0.8.0", features = ["rocket-handlers"] }
3644
```
3745

3846
## Building schemas
@@ -100,7 +108,7 @@ graphql_object!(Human: () |&self| {
100108
```
101109

102110
You can find the full example in [src/tests/schema.rs][test_schema_rs],
103-
including polymorphism with traits and interfaces. For an example of the Iron
111+
including polymorphism with traits and interfaces. For an example of framework
104112
integration, see the [examples folder][examples].
105113

106114
## Features
@@ -120,7 +128,7 @@ Juniper has not reached 1.0 yet, thus some API instability should be expected.
120128

121129
## 1.0 Roadmap
122130

123-
> Version 0.7.0 probably be re-released as 1.0 to indicate API stability.
131+
> Version 0.8.0 probably be re-released as 1.0 to indicate API stability.
124132
125133
The road to 1.0 _focuses_ on two aspects: making sure the API hasn't got any
126134
obvious dead-ends with respect to probable future features, and improving test
@@ -150,3 +158,4 @@ as well.
150158
[test_schema_rs]: src/tests/schema.rs
151159
[tokio]: https://github.com/tokio-rs/tokio
152160
[examples]: examples/
161+
[Rocket]: https://rocket.rs

src/http.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1+
//! Utilities for building HTTP endpoints in a library-agnostic manner
2+
13
use serde::ser;
24
use serde::ser::SerializeMap;
35

46
use ::{GraphQLError, Value, Variables, GraphQLType, RootNode};
57
use ast::InputValue;
68
use executor::ExecutionError;
79

8-
/// The expected structure of the decoded JSON Document for either Post or Get requests.
10+
/// The expected structure of the decoded JSON document for either POST or GET requests.
11+
///
12+
/// For POST, you can use Serde to deserialize the incoming JSON data directly
13+
/// into this struct - it derives Deserialize for exactly this reason.
14+
///
15+
/// For GET, you will need to parse the query string and exctract "query",
16+
/// "operationName", and "variables" manually.
917
#[derive(Deserialize)]
1018
pub struct GraphQLRequest {
1119
query: String,
@@ -27,6 +35,7 @@ impl GraphQLRequest {
2735
}).unwrap_or_default()
2836
}
2937

38+
/// Construct a new GraphQL request from parts
3039
pub fn new(query: String, operation_name: Option<String>, variables: Option<InputValue>) -> GraphQLRequest {
3140
GraphQLRequest {
3241
query: query,
@@ -35,6 +44,10 @@ impl GraphQLRequest {
3544
}
3645
}
3746

47+
/// Execute a GraphQL request using the specified schema and context
48+
///
49+
/// This is a simple wrapper around the `execute` function exposed at the
50+
/// top level of this crate.
3851
pub fn execute<'a, CtxT, QueryT, MutationT>(
3952
&'a self,
4053
root_node: &RootNode<QueryT, MutationT>,
@@ -54,10 +67,18 @@ impl GraphQLRequest {
5467
}
5568
}
5669

57-
70+
/// Simple wrapper around the result from executing a GraphQL query
71+
///
72+
/// This struct implements Serialize, so you can simply serialize this
73+
/// to JSON and send it over the wire. Use the `is_ok` method to determine
74+
/// whether to send a 200 or 400 HTTP status code.
5875
pub struct GraphQLResponse<'a>(Result<(Value, Vec<ExecutionError>), GraphQLError<'a>>);
5976

6077
impl<'a> GraphQLResponse<'a> {
78+
/// Was the request successful or not?
79+
///
80+
/// Note that there still might be errors in the response even though it's
81+
/// considered OK. This is by design in GraphQL.
6182
pub fn is_ok(&self) -> bool {
6283
self.0.is_ok()
6384
}

src/integrations/iron_handlers.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
//! Optional handlers for the Iron framework. Requires the `iron-handlers` feature enabled.
1+
//! Optional handlers for the [Iron](http://ironframework.io) framework. Requires the `iron-handlers` feature enabled.
2+
//!
3+
//! See the [server.rs](https://github.com/mhallin/juniper/blob/master/examples/server.rs)
4+
//! example for more information on how to use these handlers.
5+
26
use iron::prelude::*;
37
use iron::middleware::Handler;
48
use iron::mime::Mime;

src/integrations/rocket_handlers.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
//! Optional helper functions for the [Rocket](https://rocket.rs) framework. Requires the "rocket-handlers" feature enabled.
2+
//!
3+
//! The two exposed types in this module are simple wrapper around the
4+
//! types exposed by the `http` module, but they are better suited for use
5+
//! in handler functions in the Rocket framework.
6+
//!
7+
//! See the [rocket-server.rs](https://github.com/mhallin/juniper/blob/master/examples/rocket-server.rs)
8+
//! example for how to use these tools.
9+
110
use std::io::{Cursor, Read};
211
use std::error::Error;
312

@@ -17,14 +26,23 @@ use ::http;
1726
use types::base::GraphQLType;
1827
use schema::model::RootNode;
1928

20-
pub struct GraphQLResponse(Status, String);
29+
/// Simple wrapper around an incoming GraphQL request
30+
///
31+
/// See the `http` module for more information. This type can be constructed
32+
/// automatically from both GET and POST routes by implementing the `FromForm`
33+
/// and `FromData` traits.
2134
pub struct GraphQLRequest(http::GraphQLRequest);
2235

36+
/// Simple wrapper around the result of executing a GraphQL query
37+
pub struct GraphQLResponse(Status, String);
38+
39+
/// Generate an HTML page containing GraphiQL
2340
pub fn graphiql_source(graphql_endpoint_url: &str) -> content::HTML<String> {
2441
content::HTML(::graphiql::graphiql_source(graphql_endpoint_url))
2542
}
2643

2744
impl GraphQLRequest {
45+
/// Execute an incoming GraphQL query
2846
pub fn execute<CtxT, QueryT, MutationT>(
2947
&self,
3048
root_node: &RootNode<QueryT, MutationT>,

src/lib.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ statically verify their queries against a server without actually executing
1010
them.
1111
1212
This library provides data types and traits to expose Rust types in a GraphQL
13-
schema, as well as an optional integration into the [Iron framework][2]. It
14-
tries to keep the number of dynamic operations to a minimum, and give you as the
15-
schema developer the control of the query execution path.
13+
schema, as well as an optional integration into the [Iron framework][2] and
14+
[Rocket]. It tries to keep the number of dynamic operations to a minimum, and
15+
give you as the schema developer the control of the query execution path.
1616
1717
Juniper only depends on `serde` and `serde_derive` by default, making it
18-
lightweight and easy to drop into any project. Through the `iron-handlers`
19-
feature, it also depends on Iron.
18+
lightweight and easy to drop into any project. If you enable any of the
19+
optional framework integrations, it will naturally depend on those frameworks
20+
too.
2021
2122
## Exposing data types
2223
@@ -98,9 +99,11 @@ the [`graphql_object!`][3] macro.
9899
## Integrating with Iron
99100
100101
The most obvious usecase is to expose the GraphQL schema over an HTTP endpoint.
101-
To support this, the library provides an optional and customizable Iron handler.
102+
To support this, the library provides optional and customizable handlers for
103+
both Iron and Rocket.
102104
103-
For example, continuing from the schema created above:
105+
For example, continuing from the schema created above and using Iron to expose
106+
the schema on an HTTP endpoint supporting both GET and POST requests:
104107
105108
```rust,no_run
106109
extern crate iron;
@@ -180,6 +183,7 @@ built-in [GraphiQL][6] handler included.
180183
[4]: iron_handlers/index.html
181184
[5]: iron_handlers/struct.GraphQLHandler.html
182185
[6]: https://github.com/graphql/graphiql
186+
[Rocket]: https://rocket.rs
183187
184188
*/
185189

0 commit comments

Comments
 (0)