Remove macro_use + extern crate statements (2018 edition)

This commit is contained in:
Christoph Herzog 2019-04-23 02:19:06 +02:00
parent 54a1b64a79
commit 5a4230e0d0
No known key found for this signature in database
GPG key ID: DAFF71D48B493238
39 changed files with 134 additions and 171 deletions

View file

@ -127,8 +127,7 @@ You can invoke `juniper::execute` directly to run a GraphQL query:
```rust ```rust
# // Only needed due to 2018 edition because the macro is not accessible. # // Only needed due to 2018 edition because the macro is not accessible.
# #[macro_use] # #[macro_use] extern crate juniper;
# extern crate juniper;
use juniper::{FieldResult, Variables, EmptyMutation}; use juniper::{FieldResult, Variables, EmptyMutation};
#[derive(juniper::GraphQLEnum, Clone, Copy)] #[derive(juniper::GraphQLEnum, Clone, Copy)]

View file

@ -129,7 +129,7 @@ impl juniper::IntoFieldError for CustomError {
match self { match self {
CustomError::WhateverNotSet => juniper::FieldError::new( CustomError::WhateverNotSet => juniper::FieldError::new(
"Whatever does not exist", "Whatever does not exist",
juniper::graphql_value!({ graphql_value!({
"type": "NO_WHATEVER" "type": "NO_WHATEVER"
}), }),
), ),

View file

@ -4,7 +4,7 @@ use fnv::FnvHashMap;
#[cfg(test)] #[cfg(test)]
use juniper::{self, DefaultScalarValue, FromInputValue, GraphQLType, InputValue, ToInputValue}; use juniper::{self, DefaultScalarValue, FromInputValue, GraphQLType, InputValue, ToInputValue};
#[derive(GraphQLEnum, Debug, PartialEq)] #[derive(juniper::GraphQLEnum, Debug, PartialEq)]
#[graphql(name = "Some", description = "enum descr")] #[graphql(name = "Some", description = "enum descr")]
enum SomeEnum { enum SomeEnum {
Regular, Regular,
@ -13,7 +13,7 @@ enum SomeEnum {
} }
/// Enum doc. /// Enum doc.
#[derive(GraphQLEnum)] #[derive(juniper::GraphQLEnum)]
enum DocEnum { enum DocEnum {
/// Variant doc. /// Variant doc.
Foo, Foo,
@ -23,7 +23,7 @@ enum DocEnum {
/// Doc 2. /// Doc 2.
/// ///
/// Doc 4. /// Doc 4.
#[derive(GraphQLEnum, Debug, PartialEq)] #[derive(juniper::GraphQLEnum, Debug, PartialEq)]
enum MultiDocEnum { enum MultiDocEnum {
/// Variant 1. /// Variant 1.
/// Variant 2. /// Variant 2.
@ -31,7 +31,7 @@ enum MultiDocEnum {
} }
/// This is not used as the description. /// This is not used as the description.
#[derive(GraphQLEnum, Debug, PartialEq)] #[derive(juniper::GraphQLEnum, Debug, PartialEq)]
#[graphql(description = "enum override")] #[graphql(description = "enum override")]
enum OverrideDocEnum { enum OverrideDocEnum {
/// This is not used as the description. /// This is not used as the description.

View file

@ -2,7 +2,7 @@
use fnv::FnvHashMap; use fnv::FnvHashMap;
use juniper::{self, FromInputValue, GraphQLType, InputValue, ToInputValue}; use juniper::{self, FromInputValue, GraphQLType, InputValue, ToInputValue};
use juniper::GraphQLInputObject;
use juniper::DefaultScalarValue; use juniper::DefaultScalarValue;
#[derive(GraphQLInputObject, Debug, PartialEq)] #[derive(GraphQLInputObject, Debug, PartialEq)]
@ -103,7 +103,7 @@ fn test_derived_input_object() {
// Test default value injection. // Test default value injection.
let input_no_defaults: InputValue = ::serde_json::from_value(json!({ let input_no_defaults: InputValue = ::serde_json::from_value(serde_json::json!({
"regularField": "a", "regularField": "a",
})) }))
.unwrap(); .unwrap();
@ -120,7 +120,7 @@ fn test_derived_input_object() {
// Test with all values supplied. // Test with all values supplied.
let input: InputValue = ::serde_json::from_value(json!({ let input: InputValue = ::serde_json::from_value(serde_json::json!({
"regularField": "a", "regularField": "a",
"haha": 55, "haha": 55,
"other": true, "other": true,

View file

@ -3,6 +3,7 @@ use fnv::FnvHashMap;
use juniper::DefaultScalarValue; use juniper::DefaultScalarValue;
#[cfg(test)] #[cfg(test)]
use juniper::Object; use juniper::Object;
use juniper::GraphQLObject;
#[cfg(test)] #[cfg(test)]
use juniper::{self, execute, EmptyMutation, GraphQLType, RootNode, Value, Variables}; use juniper::{self, execute, EmptyMutation, GraphQLType, RootNode, Value, Variables};
@ -79,7 +80,7 @@ struct WithCustomContext {
a: bool, a: bool,
} }
graphql_object!(Query: () |&self| { juniper::graphql_object!(Query: () |&self| {
field obj() -> Obj { field obj() -> Obj {
Obj{ Obj{
regular_field: true, regular_field: true,

View file

@ -9,7 +9,7 @@ use juniper::{execute, EmptyMutation, Object, RootNode, Variables};
use juniper::{InputValue, ParseScalarResult, ScalarValue, Value}; use juniper::{InputValue, ParseScalarResult, ScalarValue, Value};
use std::fmt; use std::fmt;
#[derive(Debug, Clone, PartialEq, GraphQLScalarValue)] #[derive(Debug, Clone, PartialEq, juniper::GraphQLScalarValue)]
enum MyScalarValue { enum MyScalarValue {
Int(i32), Int(i32),
Long(i64), Long(i64),
@ -126,7 +126,7 @@ impl<'de> de::Visitor<'de> for MyScalarValueVisitor {
} }
} }
graphql_scalar!(i64 as "Long" where Scalar = MyScalarValue { juniper::graphql_scalar!(i64 as "Long" where Scalar = MyScalarValue {
resolve(&self) -> Value { resolve(&self) -> Value {
Value::scalar(*self) Value::scalar(*self)
} }
@ -151,7 +151,7 @@ graphql_scalar!(i64 as "Long" where Scalar = MyScalarValue {
struct TestType; struct TestType;
graphql_object!(TestType: () where Scalar = MyScalarValue |&self| { juniper::graphql_object!(TestType: () where Scalar = MyScalarValue |&self| {
field long_field() -> i64 { field long_field() -> i64 {
(::std::i32::MAX as i64) + 1 (::std::i32::MAX as i64) + 1
} }

View file

@ -1,7 +1,5 @@
#[macro_use]
extern crate juniper; extern crate juniper;
#[cfg(test)] #[cfg(test)]
#[macro_use]
extern crate serde_json; extern crate serde_json;
#[cfg(test)] #[cfg(test)]

View file

@ -157,9 +157,10 @@ impl<S> FieldError<S> {
/// You can use the `graphql_value!` macro to construct an error: /// You can use the `graphql_value!` macro to construct an error:
/// ///
/// ```rust /// ```rust
/// # #[macro_use] extern crate juniper; /// # extern crate juniper;
/// use juniper::FieldError; /// use juniper::FieldError;
/// # use juniper::DefaultScalarValue; /// # use juniper::DefaultScalarValue;
/// use juniper::graphql_value;
/// ///
/// # fn sample() { /// # fn sample() {
/// # let _: FieldError<DefaultScalarValue> = /// # let _: FieldError<DefaultScalarValue> =

View file

@ -1,3 +1,5 @@
use juniper_codegen::GraphQLEnumInternal as GraphQLEnum;
use crate::ast::InputValue; use crate::ast::InputValue;
use crate::executor::Variables; use crate::executor::Variables;
use crate::parser::SourcePosition; use crate::parser::SourcePosition;
@ -7,7 +9,7 @@ use crate::validation::RuleError;
use crate::value::{DefaultScalarValue, Object, Value}; use crate::value::{DefaultScalarValue, Object, Value};
use crate::GraphQLError::ValidationError; use crate::GraphQLError::ValidationError;
#[derive(GraphQLEnumInternal, Debug)] #[derive(GraphQLEnum, Debug)]
enum Color { enum Color {
Red, Red,
Green, Green,

View file

@ -1,3 +1,5 @@
use juniper_codegen::GraphQLEnumInternal as GraphQLEnum;
use crate::executor::Variables; use crate::executor::Variables;
use crate::schema::model::RootNode; use crate::schema::model::RootNode;
use crate::types::scalars::EmptyMutation; use crate::types::scalars::EmptyMutation;
@ -15,33 +17,33 @@ Syntax to validate:
*/ */
#[derive(GraphQLEnumInternal)] #[derive(GraphQLEnum)]
enum DefaultName { enum DefaultName {
Foo, Foo,
Bar, Bar,
} }
#[derive(GraphQLEnumInternal)] #[derive(GraphQLEnum)]
#[graphql(name = "ANamedEnum")] #[graphql(name = "ANamedEnum")]
enum Named { enum Named {
Foo, Foo,
Bar, Bar,
} }
#[derive(GraphQLEnumInternal)] #[derive(GraphQLEnum)]
enum NoTrailingComma { enum NoTrailingComma {
Foo, Foo,
Bar, Bar,
} }
#[derive(GraphQLEnumInternal)] #[derive(GraphQLEnum)]
#[graphql(description = "A description of the enum itself")] #[graphql(description = "A description of the enum itself")]
enum EnumDescription { enum EnumDescription {
Foo, Foo,
Bar, Bar,
} }
#[derive(GraphQLEnumInternal)] #[derive(GraphQLEnum)]
enum EnumValueDescription { enum EnumValueDescription {
#[graphql(description = "The FOO value")] #[graphql(description = "The FOO value")]
Foo, Foo,
@ -49,7 +51,7 @@ enum EnumValueDescription {
Bar, Bar,
} }
#[derive(GraphQLEnumInternal)] #[derive(GraphQLEnum)]
enum EnumDeprecation { enum EnumDeprecation {
#[graphql(deprecated = "Please don't use FOO any more")] #[graphql(deprecated = "Please don't use FOO any more")]
Foo, Foo,

View file

@ -1,3 +1,5 @@
use juniper_codegen::GraphQLInputObjectInternal as GraphQLInputObject;
use crate::ast::{FromInputValue, InputValue}; use crate::ast::{FromInputValue, InputValue};
use crate::executor::Variables; use crate::executor::Variables;
use crate::schema::model::RootNode; use crate::schema::model::RootNode;
@ -6,47 +8,47 @@ use crate::value::{DefaultScalarValue, Object, Value};
struct Root; struct Root;
#[derive(GraphQLInputObjectInternal)] #[derive(GraphQLInputObject)]
struct DefaultName { struct DefaultName {
field_one: String, field_one: String,
field_two: String, field_two: String,
} }
#[derive(GraphQLInputObjectInternal)] #[derive(GraphQLInputObject)]
struct NoTrailingComma { struct NoTrailingComma {
field_one: String, field_one: String,
field_two: String, field_two: String,
} }
#[derive(GraphQLInputObjectInternal, Debug)] #[derive(GraphQLInputObject, Debug)]
struct Derive { struct Derive {
field_one: String, field_one: String,
} }
#[derive(GraphQLInputObjectInternal, Debug)] #[derive(GraphQLInputObject, Debug)]
#[graphql(name = "ANamedInputObject")] #[graphql(name = "ANamedInputObject")]
struct Named { struct Named {
field_one: String, field_one: String,
} }
#[derive(GraphQLInputObjectInternal, Debug)] #[derive(GraphQLInputObject, Debug)]
#[graphql(description = "Description for the input object")] #[graphql(description = "Description for the input object")]
struct Description { struct Description {
field_one: String, field_one: String,
} }
#[derive(GraphQLInputObjectInternal, Debug)] #[derive(GraphQLInputObject, Debug)]
pub struct Public { pub struct Public {
field_one: String, field_one: String,
} }
#[derive(GraphQLInputObjectInternal, Debug)] #[derive(GraphQLInputObject, Debug)]
#[graphql(description = "Description for the input object")] #[graphql(description = "Description for the input object")]
pub struct PublicWithDescription { pub struct PublicWithDescription {
field_one: String, field_one: String,
} }
#[derive(GraphQLInputObjectInternal, Debug)] #[derive(GraphQLInputObject, Debug)]
#[graphql( #[graphql(
name = "APublicNamedInputObjectWithDescription", name = "APublicNamedInputObjectWithDescription",
description = "Description for the input object" description = "Description for the input object"
@ -55,13 +57,13 @@ pub struct NamedPublicWithDescription {
field_one: String, field_one: String,
} }
#[derive(GraphQLInputObjectInternal, Debug)] #[derive(GraphQLInputObject, Debug)]
#[graphql(name = "APublicNamedInputObject")] #[graphql(name = "APublicNamedInputObject")]
pub struct NamedPublic { pub struct NamedPublic {
field_one: String, field_one: String,
} }
#[derive(GraphQLInputObjectInternal, Debug)] #[derive(GraphQLInputObject, Debug)]
struct FieldDescription { struct FieldDescription {
#[graphql(description = "The first field")] #[graphql(description = "The first field")]
field_one: String, field_one: String,
@ -69,7 +71,7 @@ struct FieldDescription {
field_two: String, field_two: String,
} }
#[derive(GraphQLInputObjectInternal, Debug)] #[derive(GraphQLInputObject, Debug)]
struct FieldWithDefaults { struct FieldWithDefaults {
#[graphql(default = "123")] #[graphql(default = "123")]
field_one: i32, field_one: i32,

View file

@ -1,6 +1,8 @@
mod enums; mod enums;
mod input_object; mod input_object;
use juniper_codegen::GraphQLEnumInternal as GraphQLEnum;
// This asserts that the input objects defined public actually became public // This asserts that the input objects defined public actually became public
#[allow(unused_imports)] #[allow(unused_imports)]
use self::input_object::{NamedPublic, NamedPublicWithDescription}; use self::input_object::{NamedPublic, NamedPublicWithDescription};
@ -10,7 +12,7 @@ use crate::schema::model::RootNode;
use crate::types::scalars::EmptyMutation; use crate::types::scalars::EmptyMutation;
use crate::value::{ParseScalarResult, ParseScalarValue, Value}; use crate::value::{ParseScalarResult, ParseScalarValue, Value};
#[derive(GraphQLEnumInternal)] #[derive(GraphQLEnum)]
#[graphql(name = "SampleEnum")] #[graphql(name = "SampleEnum")]
enum Sample { enum Sample {
One, One,

View file

@ -1,3 +1,5 @@
use juniper_codegen::GraphQLInputObjectInternal as GraphQLInputObject;
use crate::ast::InputValue; use crate::ast::InputValue;
use crate::executor::Variables; use crate::executor::Variables;
use crate::parser::SourcePosition; use crate::parser::SourcePosition;
@ -32,7 +34,7 @@ graphql_scalar!(TestComplexScalar {
} }
}); });
#[derive(GraphQLInputObjectInternal, Debug)] #[derive(GraphQLInputObject, Debug)]
#[graphql(scalar = "DefaultScalarValue")] #[graphql(scalar = "DefaultScalarValue")]
struct TestInputObject { struct TestInputObject {
a: Option<String>, a: Option<String>,
@ -41,20 +43,20 @@ struct TestInputObject {
d: Option<TestComplexScalar>, d: Option<TestComplexScalar>,
} }
#[derive(GraphQLInputObjectInternal, Debug)] #[derive(GraphQLInputObject, Debug)]
#[graphql(scalar = "DefaultScalarValue")] #[graphql(scalar = "DefaultScalarValue")]
struct TestNestedInputObject { struct TestNestedInputObject {
na: TestInputObject, na: TestInputObject,
nb: String, nb: String,
} }
#[derive(GraphQLInputObjectInternal, Debug)] #[derive(GraphQLInputObject, Debug)]
struct ExampleInputObject { struct ExampleInputObject {
a: Option<String>, a: Option<String>,
b: i32, b: i32,
} }
#[derive(GraphQLInputObjectInternal, Debug)] #[derive(GraphQLInputObject, Debug)]
struct InputWithDefaults { struct InputWithDefaults {
#[graphql(default = "123")] #[graphql(default = "123")]
a: i32, a: i32,

View file

@ -5,6 +5,7 @@ pub mod playground;
use serde::de::Deserialize; use serde::de::Deserialize;
use serde::ser::{self, Serialize, SerializeMap}; use serde::ser::{self, Serialize, SerializeMap};
use serde_derive::{Serialize, Deserialize};
use crate::ast::InputValue; use crate::ast::InputValue;
use crate::executor::ExecutionError; use crate::executor::ExecutionError;

View file

@ -1,6 +1,7 @@
use indexmap::IndexMap; use indexmap::IndexMap;
use serde::ser::SerializeMap; use serde::ser::SerializeMap;
use serde::{de, ser}; use serde::{de, ser};
use serde_derive::Serialize;
use std::fmt; use std::fmt;
@ -130,7 +131,7 @@ where
self.0.visit_i64(value).map(InputValue::Scalar) self.0.visit_i64(value).map(InputValue::Scalar)
} }
serde_if_integer128! { serde::serde_if_integer128! {
fn visit_i128<E>(self, value: i128) -> Result<InputValue<S>, E> fn visit_i128<E>(self, value: i128) -> Result<InputValue<S>, E>
where where
E: de::Error, E: de::Error,
@ -167,7 +168,7 @@ where
self.0.visit_u64(value).map(InputValue::Scalar) self.0.visit_u64(value).map(InputValue::Scalar)
} }
serde_if_integer128! { serde::serde_if_integer128! {
fn visit_u128<E>(self, value: u128) -> Result<InputValue<S>, E> fn visit_u128<E>(self, value: u128) -> Result<InputValue<S>, E>
where where
E: de::Error, E: de::Error,

View file

@ -91,18 +91,11 @@ Juniper has not reached 1.0 yet, thus some API instability should be expected.
#![warn(missing_docs)] #![warn(missing_docs)]
#[doc(hidden)] #[doc(hidden)]
#[macro_use]
pub extern crate serde; pub extern crate serde;
#[macro_use]
extern crate serde_derive;
#[cfg(any(test, feature = "expose-test-schema"))] #[cfg(any(test, feature = "expose-test-schema"))]
extern crate serde_json; extern crate serde_json;
extern crate fnv;
extern crate indexmap;
#[cfg(any(test, feature = "chrono"))] #[cfg(any(test, feature = "chrono"))]
extern crate chrono; extern crate chrono;
@ -115,9 +108,6 @@ extern crate uuid;
// Depend on juniper_codegen and re-export everything in it. // Depend on juniper_codegen and re-export everything in it.
// This allows users to just depend on juniper and get the derive // This allows users to just depend on juniper and get the derive
// functionality automatically. // functionality automatically.
#[allow(unused_imports)]
#[macro_use]
extern crate juniper_codegen;
#[doc(hidden)] #[doc(hidden)]
pub use juniper_codegen::*; pub use juniper_codegen::*;

View file

@ -40,7 +40,7 @@ A simplified extract from the StarWars schema example shows how to use the
shared context to implement downcasts. shared context to implement downcasts.
```rust ```rust
# #[macro_use] extern crate juniper; # extern crate juniper;
# use std::collections::HashMap; # use std::collections::HashMap;
struct Human { id: String } struct Human { id: String }
struct Droid { id: String } struct Droid { id: String }
@ -61,16 +61,16 @@ impl Character for Droid {
fn id(&self) -> &str { &self.id } fn id(&self) -> &str { &self.id }
} }
graphql_object!(Human: Database as "Human" |&self| { juniper::graphql_object!(Human: Database as "Human" |&self| {
field id() -> &str { &self.id } field id() -> &str { &self.id }
}); });
graphql_object!(Droid: Database as "Droid" |&self| { juniper::graphql_object!(Droid: Database as "Droid" |&self| {
field id() -> &str { &self.id } field id() -> &str { &self.id }
}); });
// You can introduce lifetimes or generic parameters by < > before the name. // You can introduce lifetimes or generic parameters by < > before the name.
graphql_interface!(<'a> &'a Character: Database as "Character" |&self| { juniper::graphql_interface!(<'a> &'a Character: Database as "Character" |&self| {
field id() -> &str { self.id() } field id() -> &str { self.id() }
instance_resolvers: |&context| { instance_resolvers: |&context| {

View file

@ -10,10 +10,10 @@ safety and reduce repetitive declarations.
The simplest case exposes fields on a struct: The simplest case exposes fields on a struct:
```rust ```rust
# #[macro_use] extern crate juniper; # extern crate juniper;
struct User { id: String, name: String, group_ids: Vec<String> } struct User { id: String, name: String, group_ids: Vec<String> }
graphql_object!(User: () |&self| { juniper::graphql_object!(User: () |&self| {
field id() -> &String { field id() -> &String {
&self.id &self.id
} }
@ -42,10 +42,10 @@ attributes. Alternatively the same syntax as for the type could be
used used
```rust ```rust
# #[macro_use] extern crate juniper; # extern crate juniper;
struct User { id: String, name: String, group_ids: Vec<String> } struct User { id: String, name: String, group_ids: Vec<String> }
graphql_object!(User: () |&self| { juniper::graphql_object!(User: () |&self| {
description: "A user in the database" description: "A user in the database"
@ -77,16 +77,16 @@ You can expose generic or pointer types by prefixing the type with the necessary
generic parameters: generic parameters:
```rust ```rust
# #[macro_use] extern crate juniper; # extern crate juniper;
trait SomeTrait { fn id(&self) -> &str; } trait SomeTrait { fn id(&self) -> &str; }
graphql_object!(<'a> &'a SomeTrait: () as "SomeTrait" |&self| { juniper::graphql_object!(<'a> &'a SomeTrait: () as "SomeTrait" |&self| {
field id() -> &str { self.id() } field id() -> &str { self.id() }
}); });
struct GenericType<T> { items: Vec<T> } struct GenericType<T> { items: Vec<T> }
graphql_object!(<T> GenericType<T>: () as "GenericType" |&self| { juniper::graphql_object!(<T> GenericType<T>: () as "GenericType" |&self| {
field count() -> i32 { self.items.len() as i32 } field count() -> i32 { self.items.len() as i32 }
}); });
@ -98,14 +98,14 @@ graphql_object!(<T> GenericType<T>: () as "GenericType" |&self| {
You can use the `interfaces` item to implement interfaces: You can use the `interfaces` item to implement interfaces:
```rust ```rust
# #[macro_use] extern crate juniper; # extern crate juniper;
trait Interface { trait Interface {
fn id(&self) -> &str; fn id(&self) -> &str;
fn as_implementor(&self) -> Option<Implementor>; fn as_implementor(&self) -> Option<Implementor>;
} }
struct Implementor { id: String } struct Implementor { id: String }
graphql_interface!(<'a> &'a Interface: () as "Interface" |&self| { juniper::graphql_interface!(<'a> &'a Interface: () as "Interface" |&self| {
field id() -> &str { self.id() } field id() -> &str { self.id() }
instance_resolvers: |&context| { instance_resolvers: |&context| {
@ -113,7 +113,7 @@ graphql_interface!(<'a> &'a Interface: () as "Interface" |&self| {
} }
}); });
graphql_object!(Implementor: () |&self| { juniper::graphql_object!(Implementor: () |&self| {
field id() -> &str { &self.id } field id() -> &str { &self.id }
interfaces: [&Interface] interfaces: [&Interface]
@ -140,11 +140,11 @@ automatically via the `?` operator, or you can construct them yourself using
`FieldError::new`. `FieldError::new`.
``` ```
# #[macro_use] extern crate juniper; # extern crate juniper;
# use juniper::FieldResult; # use juniper::FieldResult;
struct User { id: String } struct User { id: String }
graphql_object!(User: () |&self| { juniper::graphql_object!(User: () |&self| {
field id() -> FieldResult<&String> { field id() -> FieldResult<&String> {
Ok(&self.id) Ok(&self.id)
} }
@ -172,10 +172,10 @@ be used as type parameter to the implementing type.
Example for using a generic scalar value type Example for using a generic scalar value type
```rust ```rust
# #[macro_use] extern crate juniper; # extern crate juniper;
struct User { id: String } struct User { id: String }
graphql_object!(User: () where Scalar = <S> |&self| { juniper::graphql_object!(User: () where Scalar = <S> |&self| {
field id() -> &String { field id() -> &String {
&self.id &self.id
} }

View file

@ -17,11 +17,11 @@ possible to use the same syntax as on `graphql_object!` to specify a custom
representation. representation.
```rust ```rust
# #[macro_use] extern crate juniper; # extern crate juniper;
# use juniper::{Value, FieldResult, ParseScalarValue, ParseScalarResult}; # use juniper::{Value, FieldResult, ParseScalarValue, ParseScalarResult};
struct UserID(String); struct UserID(String);
graphql_scalar!(UserID { juniper::graphql_scalar!(UserID {
description: "An opaque identifier, represented as a string" description: "An opaque identifier, represented as a string"
resolve(&self) -> Value { resolve(&self) -> Value {

View file

@ -1,3 +1,5 @@
use juniper_codegen::GraphQLInputObjectInternal as GraphQLInputObject;
use crate::executor::Variables; use crate::executor::Variables;
use crate::schema::model::RootNode; use crate::schema::model::RootNode;
use crate::types::scalars::EmptyMutation; use crate::types::scalars::EmptyMutation;
@ -19,7 +21,7 @@ Syntax to validate:
*/ */
#[derive(GraphQLInputObjectInternal)] #[derive(GraphQLInputObject)]
struct Point { struct Point {
x: i32, x: i32,
} }

View file

@ -1,5 +1,10 @@
use indexmap::IndexMap; use indexmap::IndexMap;
use juniper_codegen::{
GraphQLInputObjectInternal as GraphQLInputObject,
GraphQLEnumInternal as GraphQLEnum,
};
use crate::ast::{FromInputValue, InputValue, Type}; use crate::ast::{FromInputValue, InputValue, Type};
use crate::parser::value::parse_value_literal; use crate::parser::value::parse_value_literal;
use crate::parser::{Lexer, Parser, SourcePosition, Spanning}; use crate::parser::{Lexer, Parser, SourcePosition, Spanning};
@ -9,17 +14,17 @@ use crate::schema::meta::{Argument, EnumMeta, EnumValue, InputObjectMeta, MetaTy
use crate::schema::model::SchemaType; use crate::schema::model::SchemaType;
use crate::types::scalars::EmptyMutation; use crate::types::scalars::EmptyMutation;
#[derive(GraphQLEnumInternal)] #[derive(GraphQLEnum)]
enum Enum { enum Enum {
EnumValue, EnumValue,
} }
#[derive(GraphQLInputObjectInternal)] #[derive(GraphQLInputObject)]
struct Bar { struct Bar {
foo: String, foo: String,
} }
#[derive(GraphQLInputObjectInternal)] #[derive(GraphQLInputObject)]
struct Foo { struct Foo {
key: i32, key: i32,
other: Bar, other: Bar,

View file

@ -2,6 +2,8 @@ use std::fmt;
use fnv::FnvHashMap; use fnv::FnvHashMap;
use juniper_codegen::GraphQLEnumInternal as GraphQLEnum;
use crate::ast::Type; use crate::ast::Type;
use crate::executor::{Context, Registry}; use crate::executor::{Context, Registry};
use crate::schema::meta::{Argument, InterfaceMeta, MetaType, ObjectMeta, PlaceholderMeta, UnionMeta}; use crate::schema::meta::{Argument, InterfaceMeta, MetaType, ObjectMeta, PlaceholderMeta, UnionMeta};
@ -57,7 +59,7 @@ pub struct DirectiveType<'a, S> {
pub arguments: Vec<Argument<'a, S>>, pub arguments: Vec<Argument<'a, S>>,
} }
#[derive(Clone, PartialEq, Eq, Debug, GraphQLEnumInternal)] #[derive(Clone, PartialEq, Eq, Debug, GraphQLEnum)]
#[graphql(name = "__DirectiveLocation")] #[graphql(name = "__DirectiveLocation")]
pub enum DirectiveLocation { pub enum DirectiveLocation {
Query, Query,

View file

@ -1,8 +1,9 @@
#![allow(missing_docs)] #![allow(missing_docs)]
use std::collections::HashMap; use std::collections::HashMap;
use juniper_codegen::GraphQLEnumInternal as GraphQLEnum;
#[derive(GraphQLEnumInternal, Copy, Clone, Eq, PartialEq, Debug)] #[derive(GraphQLEnum, Copy, Clone, Eq, PartialEq, Debug)]
pub enum Episode { pub enum Episode {
#[graphql(name = "NEW_HOPE")] #[graphql(name = "NEW_HOPE")]
NewHope, NewHope,

View file

@ -1,5 +1,7 @@
use indexmap::IndexMap; use indexmap::IndexMap;
use juniper_codegen::GraphQLEnumInternal as GraphQLEnum;
use crate::ast::{Directive, FromInputValue, InputValue, Selection}; use crate::ast::{Directive, FromInputValue, InputValue, Selection};
use crate::executor::Variables; use crate::executor::Variables;
use crate::value::{DefaultScalarValue, Object, ScalarRefValue, ScalarValue, Value}; use crate::value::{DefaultScalarValue, Object, ScalarRefValue, ScalarValue, Value};
@ -12,7 +14,7 @@ use crate::schema::meta::{Argument, MetaType};
/// ///
/// The GraphQL specification defines a number of type kinds - the meta type /// The GraphQL specification defines a number of type kinds - the meta type
/// of a type. /// of a type.
#[derive(Clone, Eq, PartialEq, Debug, GraphQLEnumInternal)] #[derive(Clone, Eq, PartialEq, Debug, GraphQLEnum)]
#[graphql(name = "__TypeKind")] #[graphql(name = "__TypeKind")]
pub enum TypeKind { pub enum TypeKind {
/// ## Scalar types /// ## Scalar types

View file

@ -1,3 +1,5 @@
use juniper_codegen::GraphQLInputObjectInternal as GraphQLInputObject;
use crate::ast::{FromInputValue, InputValue}; use crate::ast::{FromInputValue, InputValue};
use crate::executor::Registry; use crate::executor::Registry;
use crate::parser::parse_document_source; use crate::parser::parse_document_source;
@ -27,7 +29,7 @@ struct ComplicatedArgs;
pub(crate) struct QueryRoot; pub(crate) struct QueryRoot;
#[derive(Debug, GraphQLInputObjectInternal)] #[derive(Debug, GraphQLInputObject)]
struct TestInput { struct TestInput {
id: i32, id: i32,
name: String, name: String,

View file

@ -242,8 +242,8 @@ where
/// Here are some examples; the resulting JSON will look just like what you /// Here are some examples; the resulting JSON will look just like what you
/// passed in. /// passed in.
/// ```rust /// ```rust
/// #[macro_use] extern crate juniper; /// extern crate juniper;
/// # use juniper::{Value, DefaultScalarValue}; /// # use juniper::{Value, DefaultScalarValue, graphql_value};
/// # type V = Value<DefaultScalarValue>; /// # type V = Value<DefaultScalarValue>;
/// ///
/// # fn main() { /// # fn main() {

View file

@ -2,6 +2,7 @@ use crate::parser::{ParseError, ScalarToken};
use serde::de; use serde::de;
use serde::ser::Serialize; use serde::ser::Serialize;
use std::fmt::{self, Debug, Display}; use std::fmt::{self, Debug, Display};
use juniper_codegen::GraphQLScalarValueInternal as GraphQLScalarValue;
/// The result of converting a string into a scalar value /// The result of converting a string into a scalar value
pub type ParseScalarResult<'a, S = DefaultScalarValue> = Result<S, ParseError<'a>>; pub type ParseScalarResult<'a, S = DefaultScalarValue> = Result<S, ParseError<'a>>;
@ -18,7 +19,7 @@ pub trait ParseScalarValue<S = DefaultScalarValue> {
/// The main objective of this abstraction is to allow other libraries to /// The main objective of this abstraction is to allow other libraries to
/// replace the default representation with something that better fits thei /// replace the default representation with something that better fits thei
/// needs. /// needs.
/// There is a custom derive (`#[derive(GraphQLScalarValue)]`) available that implements /// There is a custom derive (`#[derive(juniper::GraphQLScalarValue)]`) available that implements
/// most of the required traits automatically for a enum representing a scalar value. /// most of the required traits automatically for a enum representing a scalar value.
/// This derives needs a additional annotation of the form /// This derives needs a additional annotation of the form
/// `#[juniper(visitor = "VisitorType")]` to specify a type that implements /// `#[juniper(visitor = "VisitorType")]` to specify a type that implements
@ -31,14 +32,13 @@ pub trait ParseScalarValue<S = DefaultScalarValue> {
/// The following example introduces an new variant that is able to store 64 bit integers. /// The following example introduces an new variant that is able to store 64 bit integers.
/// ///
/// ``` /// ```
/// # #[macro_use]
/// # extern crate juniper; /// # extern crate juniper;
/// # extern crate serde; /// # extern crate serde;
/// # use serde::{de, Deserialize, Deserializer}; /// # use serde::{de, Deserialize, Deserializer};
/// # use juniper::ScalarValue; /// # use juniper::ScalarValue;
/// # use std::fmt; /// # use std::fmt;
/// # /// #
/// #[derive(Debug, Clone, PartialEq, GraphQLScalarValue)] /// #[derive(Debug, Clone, PartialEq, juniper::GraphQLScalarValue)]
/// enum MyScalarValue { /// enum MyScalarValue {
/// Int(i32), /// Int(i32),
/// Long(i64), /// Long(i64),
@ -252,7 +252,7 @@ where
/// The default scalar value representation in juniper /// The default scalar value representation in juniper
/// ///
/// This types closely follows the graphql specification. /// This types closely follows the graphql specification.
#[derive(Debug, PartialEq, Clone, GraphQLScalarValueInternal)] #[derive(Debug, PartialEq, Clone, GraphQLScalarValue)]
#[allow(missing_docs)] #[allow(missing_docs)]
pub enum DefaultScalarValue { pub enum DefaultScalarValue {
Int(i32), Int(i32),

View file

@ -1,5 +1,6 @@
use proc_macro2::TokenStream; use proc_macro2::TokenStream;
use quote::quote;
use syn::{self, Data, DeriveInput, Fields, Variant}; use syn::{self, Data, DeriveInput, Fields, Variant};
use crate::util::*; use crate::util::*;

View file

@ -1,8 +1,8 @@
use std::str::FromStr; use std::str::FromStr;
use proc_macro2::{Span, TokenStream}; use proc_macro2::{Span, TokenStream};
use quote::ToTokens; use quote::{quote, ToTokens};
use syn::{self, Data, DeriveInput, Field, Fields, Ident, Meta, NestedMeta}; use syn::{self, Data, DeriveInput, Field, Fields, Ident, Meta, NestedMeta, parse_quote};
use crate::util::*; use crate::util::*;
@ -183,7 +183,7 @@ pub fn impl_input_object(ast: &syn::DeriveInput, is_internal: bool) -> TokenStre
Some(quote! { Default::default() }) Some(quote! { Default::default() })
} else { } else {
match field_attrs.default_expr { match field_attrs.default_expr {
Some(ref def) => match ::proc_macro::TokenStream::from_str(def) { Some(ref def) => match proc_macro::TokenStream::from_str(def) {
Ok(t) => match syn::parse::<syn::Expr>(t) { Ok(t) => match syn::parse::<syn::Expr>(t) {
Ok(e) => { Ok(e) => {
let mut tokens = TokenStream::new(); let mut tokens = TokenStream::new();

View file

@ -1,5 +1,6 @@
use proc_macro2::{Span, TokenStream}; use proc_macro2::{Span, TokenStream};
use syn::{self, Data, DeriveInput, Field, Fields, Ident}; use syn::{self, Data, DeriveInput, Field, Fields, Ident, parse_quote};
use quote::quote;
use crate::util::*; use crate::util::*;

View file

@ -1,5 +1,6 @@
use proc_macro2::TokenStream; use proc_macro2::TokenStream;
use quote::quote;
use syn::{self, Data, Fields, Ident, Variant}; use syn::{self, Data, Fields, Ident, Variant};
pub fn impl_scalar_value(ast: &syn::DeriveInput, is_internal: bool) -> TokenStream { pub fn impl_scalar_value(ast: &syn::DeriveInput, is_internal: bool) -> TokenStream {

View file

@ -7,14 +7,6 @@
#![recursion_limit = "1024"] #![recursion_limit = "1024"]
extern crate proc_macro; extern crate proc_macro;
extern crate proc_macro2;
#[macro_use]
extern crate quote;
#[macro_use]
extern crate syn;
#[macro_use]
extern crate lazy_static;
extern crate regex;
mod derive_enum; mod derive_enum;
mod derive_input_object; mod derive_input_object;

View file

@ -206,7 +206,7 @@ pub(crate) fn to_upper_snake_case(s: &str) -> String {
#[doc(hidden)] #[doc(hidden)]
pub fn is_valid_name(field_name: &str) -> bool { pub fn is_valid_name(field_name: &str) -> bool {
lazy_static! { lazy_static::lazy_static! {
static ref GRAPHQL_NAME_SPEC: Regex = Regex::new("^[_A-Za-z][_0-9A-Za-z]*$").unwrap(); static ref GRAPHQL_NAME_SPEC: Regex = Regex::new("^[_A-Za-z][_0-9A-Za-z]*$").unwrap();
} }
GRAPHQL_NAME_SPEC.is_match(field_name) GRAPHQL_NAME_SPEC.is_match(field_name)

View file

@ -1,15 +1,5 @@
#[macro_use]
extern crate futures;
extern crate hyper;
extern crate juniper;
#[macro_use]
extern crate serde_derive;
#[cfg(test)] #[cfg(test)]
extern crate reqwest; extern crate reqwest;
extern crate serde_json;
extern crate tokio;
extern crate tokio_threadpool;
extern crate url;
use futures::future::Either; use futures::future::Either;
use hyper::header::HeaderValue; use hyper::header::HeaderValue;
@ -204,7 +194,7 @@ fn new_html_response(code: StatusCode) -> Response<Body> {
resp resp
} }
#[derive(Deserialize)] #[derive(serde_derive::Deserialize)]
#[serde(untagged)] #[serde(untagged)]
#[serde(bound = "InputValue<S>: Deserialize<'de>")] #[serde(bound = "InputValue<S>: Deserialize<'de>")]
enum GraphQLRequest<S = DefaultScalarValue> enum GraphQLRequest<S = DefaultScalarValue>
@ -232,7 +222,7 @@ where
{ {
match self { match self {
GraphQLRequest::Single(request) => Either::A(future::poll_fn(move || { GraphQLRequest::Single(request) => Either::A(future::poll_fn(move || {
let res = try_ready!(tokio_threadpool::blocking( let res = futures::try_ready!(tokio_threadpool::blocking(
|| request.execute(&root_node, &context) || request.execute(&root_node, &context)
)); ));
let is_ok = res.is_ok(); let is_ok = res.is_ok();
@ -246,7 +236,7 @@ where
let root_node = root_node.clone(); let root_node = root_node.clone();
let context = context.clone(); let context = context.clone();
future::poll_fn(move || { future::poll_fn(move || {
let res = try_ready!(tokio_threadpool::blocking( let res = futures::try_ready!(tokio_threadpool::blocking(
|| request.execute(&root_node, &context) || request.execute(&root_node, &context)
)); ));
let is_ok = res.is_ok(); let is_ok = res.is_ok();

View file

@ -23,7 +23,7 @@ the schema on an HTTP endpoint supporting both GET and POST requests:
```rust,no_run ```rust,no_run
extern crate iron; extern crate iron;
# #[macro_use] extern crate juniper; # extern crate juniper;
# extern crate juniper_iron; # extern crate juniper_iron;
# use std::collections::HashMap; # use std::collections::HashMap;
@ -37,7 +37,7 @@ use juniper::{Context, EmptyMutation};
# struct QueryRoot; # struct QueryRoot;
# struct Database { users: HashMap<String, User> } # struct Database { users: HashMap<String, User> }
# #
# graphql_object!(User: Database |&self| { # juniper::graphql_object!(User: Database |&self| {
# field id() -> FieldResult<&String> { # field id() -> FieldResult<&String> {
# Ok(&self.id) # Ok(&self.id)
# } # }
@ -53,7 +53,7 @@ use juniper::{Context, EmptyMutation};
# } # }
# }); # });
# #
# graphql_object!(QueryRoot: Database |&self| { # juniper::graphql_object!(QueryRoot: Database |&self| {
# field user(&executor, id: String) -> FieldResult<Option<&User>> { # field user(&executor, id: String) -> FieldResult<Option<&User>> {
# Ok(executor.context().users.get(&id)) # Ok(executor.context().users.get(&id))
# } # }
@ -101,18 +101,12 @@ supported.
*/ */
#[macro_use]
extern crate iron;
#[cfg(test)] #[cfg(test)]
extern crate iron_test; extern crate iron_test;
extern crate juniper;
extern crate serde_json;
#[macro_use]
extern crate serde_derive;
#[cfg(test)] #[cfg(test)]
extern crate url; extern crate url;
extern crate urlencoded;
use iron::itry;
use iron::method; use iron::method;
use iron::middleware::Handler; use iron::middleware::Handler;
use iron::mime::Mime; use iron::mime::Mime;
@ -130,7 +124,7 @@ use juniper::http;
use juniper::serde::Deserialize; use juniper::serde::Deserialize;
use juniper::{DefaultScalarValue, GraphQLType, InputValue, RootNode, ScalarRefValue, ScalarValue}; use juniper::{DefaultScalarValue, GraphQLType, InputValue, RootNode, ScalarRefValue, ScalarValue};
#[derive(Deserialize)] #[derive(serde_derive::Deserialize)]
#[serde(untagged)] #[serde(untagged)]
#[serde(bound = "InputValue<S>: Deserialize<'de>")] #[serde(bound = "InputValue<S>: Deserialize<'de>")]
enum GraphQLBatchRequest<S = DefaultScalarValue> enum GraphQLBatchRequest<S = DefaultScalarValue>
@ -141,7 +135,7 @@ where
Batch(Vec<http::GraphQLRequest<S>>), Batch(Vec<http::GraphQLRequest<S>>),
} }
#[derive(Serialize)] #[derive(serde_derive::Serialize)]
#[serde(untagged)] #[serde(untagged)]
enum GraphQLBatchResponse<'a, S = DefaultScalarValue> enum GraphQLBatchResponse<'a, S = DefaultScalarValue>
where where

View file

@ -1,10 +1,5 @@
#![feature(decl_macro, proc_macro_hygiene)] #![feature(decl_macro, proc_macro_hygiene)]
extern crate juniper;
extern crate juniper_rocket;
#[macro_use]
extern crate rocket;
use rocket::response::content; use rocket::response::content;
use rocket::State; use rocket::State;
@ -13,12 +8,12 @@ use juniper::{EmptyMutation, RootNode};
type Schema = RootNode<'static, Database, EmptyMutation<Database>>; type Schema = RootNode<'static, Database, EmptyMutation<Database>>;
#[get("/")] #[rocket::get("/")]
fn graphiql() -> content::Html<String> { fn graphiql() -> content::Html<String> {
juniper_rocket::graphiql_source("/graphql") juniper_rocket::graphiql_source("/graphql")
} }
#[get("/graphql?<request>")] #[rocket::get("/graphql?<request>")]
fn get_graphql_handler( fn get_graphql_handler(
context: State<Database>, context: State<Database>,
request: juniper_rocket::GraphQLRequest, request: juniper_rocket::GraphQLRequest,
@ -27,7 +22,7 @@ fn get_graphql_handler(
request.execute(&schema, &context) request.execute(&schema, &context)
} }
#[post("/graphql", data = "<request>")] #[rocket::post("/graphql", data = "<request>")]
fn post_graphql_handler( fn post_graphql_handler(
context: State<Database>, context: State<Database>,
request: juniper_rocket::GraphQLRequest, request: juniper_rocket::GraphQLRequest,
@ -45,7 +40,7 @@ fn main() {
)) ))
.mount( .mount(
"/", "/",
routes![graphiql, get_graphql_handler, post_graphql_handler], rocket::routes![graphiql, get_graphql_handler, post_graphql_handler],
) )
.launch(); .launch();
} }

View file

@ -38,12 +38,6 @@ Check the LICENSE file for details.
#![feature(decl_macro, proc_macro_hygiene)] #![feature(decl_macro, proc_macro_hygiene)]
extern crate juniper;
extern crate rocket;
extern crate serde_json;
#[macro_use]
extern crate serde_derive;
use std::error::Error; use std::error::Error;
use std::io::{Cursor, Read}; use std::io::{Cursor, Read};
@ -66,7 +60,7 @@ use juniper::RootNode;
use juniper::ScalarRefValue; use juniper::ScalarRefValue;
use juniper::ScalarValue; use juniper::ScalarValue;
#[derive(Debug, Deserialize, PartialEq)] #[derive(Debug, serde_derive::Deserialize, PartialEq)]
#[serde(untagged)] #[serde(untagged)]
#[serde(bound = "InputValue<S>: Deserialize<'de>")] #[serde(bound = "InputValue<S>: Deserialize<'de>")]
enum GraphQLBatchRequest<S = DefaultScalarValue> enum GraphQLBatchRequest<S = DefaultScalarValue>
@ -77,7 +71,7 @@ where
Batch(Vec<http::GraphQLRequest<S>>), Batch(Vec<http::GraphQLRequest<S>>),
} }
#[derive(Serialize)] #[derive(serde_derive::Serialize)]
#[serde(untagged)] #[serde(untagged)]
enum GraphQLBatchResponse<'a, S = DefaultScalarValue> enum GraphQLBatchResponse<'a, S = DefaultScalarValue>
where where
@ -191,7 +185,7 @@ impl GraphQLResponse {
/// # /// #
/// # extern crate juniper; /// # extern crate juniper;
/// # extern crate juniper_rocket; /// # extern crate juniper_rocket;
/// # #[macro_use] extern crate rocket; /// # extern crate rocket;
/// # /// #
/// # use rocket::http::Cookies; /// # use rocket::http::Cookies;
/// # use rocket::request::Form; /// # use rocket::request::Form;
@ -203,7 +197,7 @@ impl GraphQLResponse {
/// # /// #
/// # type Schema = RootNode<'static, Database, EmptyMutation<Database>>; /// # type Schema = RootNode<'static, Database, EmptyMutation<Database>>;
/// # /// #
/// #[get("/graphql?<request..>")] /// #[rocket::get("/graphql?<request..>")]
/// fn get_graphql_handler( /// fn get_graphql_handler(
/// mut cookies: Cookies, /// mut cookies: Cookies,
/// context: State<Database>, /// context: State<Database>,

View file

@ -1,15 +1,10 @@
#![deny(warnings)] #![deny(warnings)]
extern crate env_logger; extern crate log;
#[macro_use]
extern crate log as irrelevant_log;
extern crate juniper;
extern crate juniper_warp;
extern crate warp;
use juniper::tests::model::Database; use juniper::tests::model::Database;
use juniper::{EmptyMutation, RootNode}; use juniper::{EmptyMutation, RootNode};
use warp::{http::Response, log, Filter}; use warp::{http::Response, Filter};
type Schema = RootNode<'static, Database, EmptyMutation<Database>>; type Schema = RootNode<'static, Database, EmptyMutation<Database>>;
@ -21,7 +16,7 @@ fn main() {
::std::env::set_var("RUST_LOG", "warp_server"); ::std::env::set_var("RUST_LOG", "warp_server");
env_logger::init(); env_logger::init();
let log = log("warp_server"); let log = warp::log("warp_server");
let homepage = warp::path::end().map(|| { let homepage = warp::path::end().map(|| {
Response::builder() Response::builder()
@ -31,7 +26,7 @@ fn main() {
)) ))
}); });
info!("Listening on 127.0.0.1:8080"); log::info!("Listening on 127.0.0.1:8080");
let state = warp::any().map(move || Database::new()); let state = warp::any().map(move || Database::new());
let graphql_filter = juniper_warp::make_graphql_filter(schema(), state.boxed()); let graphql_filter = juniper_warp::make_graphql_filter(schema(), state.boxed());

View file

@ -39,27 +39,13 @@ Check the LICENSE file for details.
#![deny(missing_docs)] #![deny(missing_docs)]
#![deny(warnings)] #![deny(warnings)]
#[macro_use]
extern crate failure;
extern crate futures;
extern crate juniper;
#[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate serde_json;
extern crate tokio_threadpool;
extern crate warp;
#[cfg(test)]
extern crate percent_encoding;
use futures::{future::poll_fn, Future}; use futures::{future::poll_fn, Future};
use juniper::{DefaultScalarValue, InputValue, ScalarRefValue, ScalarValue}; use juniper::{DefaultScalarValue, InputValue, ScalarRefValue, ScalarValue};
use serde::Deserialize; use serde::Deserialize;
use std::sync::Arc; use std::sync::Arc;
use warp::{filters::BoxedFilter, Filter}; use warp::{filters::BoxedFilter, Filter};
#[derive(Debug, Deserialize, PartialEq)] #[derive(Debug, serde_derive::Deserialize, PartialEq)]
#[serde(untagged)] #[serde(untagged)]
#[serde(bound = "InputValue<S>: Deserialize<'de>")] #[serde(bound = "InputValue<S>: Deserialize<'de>")]
enum GraphQLBatchRequest<S = DefaultScalarValue> enum GraphQLBatchRequest<S = DefaultScalarValue>
@ -98,7 +84,7 @@ where
} }
} }
#[derive(Serialize)] #[derive(serde_derive::Serialize)]
#[serde(untagged)] #[serde(untagged)]
enum GraphQLBatchResponse<'a, S = DefaultScalarValue> enum GraphQLBatchResponse<'a, S = DefaultScalarValue>
where where
@ -132,7 +118,6 @@ where
/// ///
/// ``` /// ```
/// # extern crate juniper_warp; /// # extern crate juniper_warp;
/// # #[macro_use]
/// # extern crate juniper; /// # extern crate juniper;
/// # extern crate warp; /// # extern crate warp;
/// # /// #
@ -149,7 +134,7 @@ where
/// ///
/// struct QueryRoot; /// struct QueryRoot;
/// ///
/// graphql_object! (QueryRoot: ExampleContext |&self| { /// juniper::graphql_object! (QueryRoot: ExampleContext |&self| {
/// field say_hello(&executor) -> String { /// field say_hello(&executor) -> String {
/// let context = executor.context(); /// let context = executor.context();
/// ///
@ -226,7 +211,7 @@ where
let graphql_request = juniper::http::GraphQLRequest::new( let graphql_request = juniper::http::GraphQLRequest::new(
request.remove("query").ok_or_else(|| { request.remove("query").ok_or_else(|| {
format_err!("Missing GraphQL query string in query parameters") failure::format_err!("Missing GraphQL query string in query parameters")
})?, })?,
request.get("operation_name").map(|s| s.to_owned()), request.get("operation_name").map(|s| s.to_owned()),
variables, variables,