Drop i64 support, add i32 support

This is a breaking change, but having i64 support is both against the
specification and a bad idea when interfacing with e.g. JavaScript or
transmitting it via JSON
This commit is contained in:
Magnus Hallin 2017-06-15 10:48:58 +02:00
parent cecf50735b
commit 8e104204a3
23 changed files with 140 additions and 140 deletions

View file

@ -203,7 +203,7 @@ using the macros and not deriving `GraphQLType` directly.
// Each entity has its own context
struct TopContext {
entities: HashMap<i64, EntityContext>,
entities: HashMap<i32, EntityContext>,
db: DatabaseConnection,
}
@ -219,7 +219,7 @@ using the macros and not deriving `GraphQLType` directly.
// to switch out the context for the returned value. You can wrap the
// tuple in Option<>, FieldResult<>, FieldResult<Option<>>, or just return
// the tuple without wrapping it.
field entity(&executor, key: i64) -> Option<(&EntityContext, Entity)> {
field entity(&executor, key: i32) -> Option<(&EntityContext, Entity)> {
executor.context().entities.get(&key)
.map(|ctx| (ctx, executor.context().db.get_entity(key)))
}
@ -247,7 +247,7 @@ using the macros and not deriving `GraphQLType` directly.
```rust
graphql_object(MyType: Database |&self| {
field count(&executor) -> FieldResult<i64> {
field count(&executor) -> FieldResult<i32> {
let txn = jtry!(executor.context().transaction());
let count = jtry!(txn.execute("SELECT COUNT(*) FROM user"));

View file

@ -37,7 +37,7 @@ pub enum Type<'a> {
#[allow(missing_docs)]
pub enum InputValue {
Null,
Int(i64),
Int(i32),
Float(f64),
String(String),
Boolean(bool),
@ -208,7 +208,7 @@ impl InputValue {
pub fn null() -> InputValue { InputValue::Null }
/// Construct an integer value.
pub fn int(i: i64) -> InputValue { InputValue::Int(i) }
pub fn int(i: i32) -> InputValue { InputValue::Int(i) }
/// Construct a floating point value.
pub fn float(f: f64) -> InputValue { InputValue::Float(f) }
@ -310,7 +310,7 @@ impl InputValue {
}
/// View the underlying int value, if present.
pub fn as_int_value(&self) -> Option<i64> {
pub fn as_int_value(&self) -> Option<i32> {
match *self {
InputValue::Int(i) => Some(i),
_ => None,

View file

@ -15,7 +15,7 @@ mod field_execution {
field e() -> &str { "Egg" }
field f() -> &str { "Fish" }
field pic(size: Option<i64>) -> String {
field pic(size: Option<i32>) -> String {
format!("Pic of size: {}", size.unwrap_or(50))
}
@ -219,7 +219,7 @@ mod dynamic_context_switching {
}
struct OuterContext {
items: HashMap<i64, InnerContext>,
items: HashMap<i32, InnerContext>,
}
impl Context for OuterContext {}
@ -228,17 +228,17 @@ mod dynamic_context_switching {
struct ItemRef;
graphql_object!(Schema: OuterContext |&self| {
field item_opt(&executor, key: i64) -> Option<(&InnerContext, ItemRef)> {
field item_opt(&executor, key: i32) -> Option<(&InnerContext, ItemRef)> {
executor.context().items.get(&key).map(|c| (c, ItemRef))
}
field item_res(&executor, key: i64) -> FieldResult<(&InnerContext, ItemRef)> {
field item_res(&executor, key: i32) -> FieldResult<(&InnerContext, ItemRef)> {
executor.context().items.get(&key)
.ok_or(format!("Could not find key {}", key))
.map(|c| (c, ItemRef))
}
field item_res_opt(&executor, key: i64) -> FieldResult<Option<(&InnerContext, ItemRef)>> {
field item_res_opt(&executor, key: i32) -> FieldResult<Option<(&InnerContext, ItemRef)>> {
if key > 100 {
Err(format!("Key too large: {}", key))
} else {
@ -247,7 +247,7 @@ mod dynamic_context_switching {
}
}
field item_always(&executor, key: i64) -> (&InnerContext, ItemRef) {
field item_always(&executor, key: i32) -> (&InnerContext, ItemRef) {
executor.context().items.get(&key)
.map(|c| (c, ItemRef))
.unwrap()

View file

@ -8,7 +8,7 @@ enum Sample {
Two,
}
struct Scalar(i64);
struct Scalar(i32);
struct Interface {}
@ -51,8 +51,8 @@ graphql_object!(Root: () |&self| {
}
field sample_scalar(
first: i64 as "The first number",
second = 123: i64 as "The second number"
first: i32 as "The first number",
second = 123: i32 as "The second number"
) -> Scalar as "A sample scalar field on the object" {
Scalar(first + second)
}

View file

@ -53,14 +53,14 @@ graphql_input_object!(
#[derive(Debug)]
struct ExampleInputObject {
a: Option<String>,
b: i64,
b: i32,
}
);
graphql_input_object!(
#[derive(Debug)]
struct InputWithDefaults {
a = 123: i64,
a = 123: i32,
}
);
@ -109,7 +109,7 @@ graphql_object!(TestType: () |&self| {
format!("a: {:?}", arg.a)
}
field integer_input(value: i64) -> String {
field integer_input(value: i32) -> String {
format!("value: {}", value)
}

View file

@ -71,7 +71,7 @@ impl<'de> de::Deserialize<'de> for InputValue {
where E: de::Error,
{
if value >= i32::min_value() as i64 && value <= i32::max_value() as i64 {
Ok(InputValue::int(value))
Ok(InputValue::int(value as i32))
}
else {
Err(E::custom(format!("integer out of range")))
@ -146,7 +146,7 @@ impl ser::Serialize for InputValue {
{
match *self {
InputValue::Null | InputValue::Variable(_) => serializer.serialize_unit(),
InputValue::Int(v) => serializer.serialize_i64(v),
InputValue::Int(v) => serializer.serialize_i64(v as i64),
InputValue::Float(v) => serializer.serialize_f64(v),
InputValue::String(ref v) | InputValue::Enum(ref v) => serializer.serialize_str(v),
InputValue::Boolean(v) => serializer.serialize_bool(v),
@ -226,7 +226,7 @@ impl ser::Serialize for Value {
{
match *self {
Value::Null => serializer.serialize_unit(),
Value::Int(v) => serializer.serialize_i64(v),
Value::Int(v) => serializer.serialize_i64(v as i64),
Value::Float(v) => serializer.serialize_f64(v),
Value::String(ref v) => serializer.serialize_str(v),
Value::Boolean(v) => serializer.serialize_bool(v),

View file

@ -37,7 +37,7 @@ is similar to argument default values:
#
graphql_input_object!(
struct SampleObject {
foo = 123: i64 as "A sample field, defaults to 123 if omitted"
foo = 123: i32 as "A sample field, defaults to 123 if omitted"
}
);

View file

@ -79,7 +79,7 @@ graphql_object!(<'a> &'a SomeTrait: () as "SomeTrait" |&self| {
struct GenericType<T> { items: Vec<T> }
graphql_object!(<T> GenericType<T>: () as "GenericType" |&self| {
field count() -> i64 { self.items.len() as i64 }
field count() -> i32 { self.items.len() as i32 }
});
# fn main() { }
@ -215,9 +215,9 @@ default value, _or_ make the type into an `Option<>`, the argument becomes
optional. For example:
```text
arg_name: i64 -- required
arg_name: Option<i64> -- optional, None if unspecified
arg_name = 123: i64 -- optional, "123" if unspecified
arg_name: i32 -- required
arg_name: Option<i32> -- optional, None if unspecified
arg_name = 123: i32 -- optional, "123" if unspecified
```
Due to some syntactical limitations in the macros, you must parentesize more

View file

@ -22,59 +22,59 @@ Syntax to validate:
graphql_input_object!(
#[derive(Debug)]
struct Point {
x: i64,
x: i32,
}
);
graphql_object!(Root: () |&self| {
field simple() -> i64 { 0 }
field exec_arg(&executor) -> i64 { 0 }
field exec_arg_and_more(&executor, arg: i64) -> i64 { 0 }
field simple() -> i32 { 0 }
field exec_arg(&executor) -> i32 { 0 }
field exec_arg_and_more(&executor, arg: i32) -> i32 { 0 }
field single_arg(arg: i64) -> i64 { 0 }
field single_arg(arg: i32) -> i32 { 0 }
field multi_args(
arg1: i64,
arg2: i64
) -> i64 { 0 }
arg1: i32,
arg2: i32
) -> i32 { 0 }
field multi_args_trailing_comma(
arg1: i64,
arg2: i64,
) -> i64 { 0 }
arg1: i32,
arg2: i32,
) -> i32 { 0 }
field single_arg_descr(arg: i64 as "The arg") -> i64 { 0 }
field single_arg_descr(arg: i32 as "The arg") -> i32 { 0 }
field multi_args_descr(
arg1: i64 as "The first arg",
arg2: i64 as "The second arg"
) -> i64 { 0 }
arg1: i32 as "The first arg",
arg2: i32 as "The second arg"
) -> i32 { 0 }
field multi_args_descr_trailing_comma(
arg1: i64 as "The first arg",
arg2: i64 as "The second arg",
) -> i64 { 0 }
arg1: i32 as "The first arg",
arg2: i32 as "The second arg",
) -> i32 { 0 }
field arg_with_default(arg = 123: i64) -> i64 { 0 }
field arg_with_default(arg = 123: i32) -> i32 { 0 }
field multi_args_with_default(
arg1 = 123: i64,
arg2 = 456: i64
) -> i64 { 0 }
arg1 = 123: i32,
arg2 = 456: i32
) -> i32 { 0 }
field multi_args_with_default_trailing_comma(
arg1 = 123: i64,
arg2 = 456: i64,
) -> i64 { 0 }
arg1 = 123: i32,
arg2 = 456: i32,
) -> i32 { 0 }
field arg_with_default_descr(arg = 123: i64 as "The arg") -> i64 { 0 }
field arg_with_default_descr(arg = 123: i32 as "The arg") -> i32 { 0 }
field multi_args_with_default_descr(
arg1 = 123: i64 as "The first arg",
arg2 = 456: i64 as "The second arg"
) -> i64 { 0 }
arg1 = 123: i32 as "The first arg",
arg2 = 456: i32 as "The second arg"
) -> i32 { 0 }
field multi_args_with_default_trailing_comma_descr(
arg1 = 123: i64 as "The first arg",
arg2 = 456: i64 as "The second arg",
) -> i64 { 0 }
arg1 = 123: i32 as "The first arg",
arg2 = 456: i32 as "The second arg",
) -> i32 { 0 }
field args_with_complex_default(
arg1 = ("test".to_owned()): String as "A string default argument",
arg2 = (Point { x: 1 }): Point as "An input object default argument",
) -> i64 { 0 }
) -> i32 { 0 }
});
fn run_args_info_query<F>(field_name: &str, f: F)

View file

@ -22,35 +22,35 @@ Syntax to validate:
*/
graphql_object!(Root: () |&self| {
field simple() -> i64 { 0 }
field simple() -> i32 { 0 }
field description() -> i64 as "Field description" { 0 }
field description() -> i32 as "Field description" { 0 }
field deprecated "Deprecation reason"
deprecated() -> i64 { 0 }
deprecated() -> i32 { 0 }
field deprecated "Deprecation reason"
deprecated_descr() -> i64 as "Field description" { 0 }
deprecated_descr() -> i32 as "Field description" { 0 }
field with_field_result() -> FieldResult<i64> { Ok(0) }
field with_field_result() -> FieldResult<i32> { Ok(0) }
field with_return() -> i64 { return 0; }
field with_return() -> i32 { return 0; }
field with_return_field_result() -> FieldResult<i64> { return Ok(0); }
field with_return_field_result() -> FieldResult<i32> { return Ok(0); }
interfaces: [Interface]
});
graphql_interface!(Interface: () |&self| {
field simple() -> i64 { 0 }
field simple() -> i32 { 0 }
field description() -> i64 as "Field description" { 0 }
field description() -> i32 as "Field description" { 0 }
field deprecated "Deprecation reason"
deprecated() -> i64 { 0 }
deprecated() -> i32 { 0 }
field deprecated "Deprecation reason"
deprecated_descr() -> i64 as "Field description" { 0 }
deprecated_descr() -> i32 as "Field description" { 0 }
instance_resolvers: |&_| {
Root => Some(Root {}),

View file

@ -80,8 +80,8 @@ graphql_input_object!(
graphql_input_object!(
struct FieldWithDefaults {
field_one = 123: i64,
field_two = 456: i64 as "The second field",
field_one = 123: i32,
field_two = 456: i32 as "The second field",
}
);
@ -98,7 +98,7 @@ graphql_object!(Root: () |&self| {
a9: NamedPublicWithDescription,
a10: NamedPublic,
a11: FieldWithDefaults,
) -> i64 {
) -> i32 {
0
}
});

View file

@ -23,7 +23,7 @@ struct Concrete;
struct CustomName;
#[allow(dead_code)]
struct WithLifetime<'a> { data: PhantomData<&'a i64> }
struct WithLifetime<'a> { data: PhantomData<&'a i32> }
#[allow(dead_code)]
struct WithGenerics<T> { data: T }
@ -40,23 +40,23 @@ struct ResolversWithTrailingComma;
struct Root;
graphql_object!(Concrete: () |&self| {
field simple() -> i64 { 0 }
field simple() -> i32 { 0 }
});
graphql_interface!(CustomName: () as "ACustomNamedInterface" |&self| {
field simple() -> i64 { 0 }
field simple() -> i32 { 0 }
instance_resolvers: |_| { Concrete => Some(Concrete) }
});
graphql_interface!(<'a> WithLifetime<'a>: () as "WithLifetime" |&self| {
field simple() -> i64 { 0 }
field simple() -> i32 { 0 }
instance_resolvers: |_| { Concrete => Some(Concrete) }
});
graphql_interface!(<T> WithGenerics<T>: () as "WithGenerics" |&self| {
field simple() -> i64 { 0 }
field simple() -> i32 { 0 }
instance_resolvers: |_| { Concrete => Some(Concrete) }
});
@ -64,13 +64,13 @@ graphql_interface!(<T> WithGenerics<T>: () as "WithGenerics" |&self| {
graphql_interface!(DescriptionFirst: () |&self| {
description: "A description"
field simple() -> i64 { 0 }
field simple() -> i32 { 0 }
instance_resolvers: |_| { Concrete => Some(Concrete) }
});
graphql_interface!(FieldsFirst: () |&self| {
field simple() -> i64 { 0 }
field simple() -> i32 { 0 }
description: "A description"
@ -80,7 +80,7 @@ graphql_interface!(FieldsFirst: () |&self| {
graphql_interface!(InterfacesFirst: () |&self| {
instance_resolvers: |_| { Concrete => Some(Concrete) }
field simple() -> i64 { 0 }
field simple() -> i32 { 0 }
description: "A description"
});
@ -88,7 +88,7 @@ graphql_interface!(InterfacesFirst: () |&self| {
graphql_interface!(CommasWithTrailing: () |&self| {
instance_resolvers: |_| { Concrete => Some(Concrete) },
field simple() -> i64 { 0 },
field simple() -> i32 { 0 },
description: "A description",
});
@ -98,7 +98,7 @@ graphql_interface!(CommasOnMeta: () |&self| {
instance_resolvers: |_| { Concrete => Some(Concrete) }
description: "A description",
field simple() -> i64 { 0 }
field simple() -> i32 { 0 }
});
@ -106,14 +106,14 @@ graphql_interface!(ResolversWithTrailingComma: () |&self| {
instance_resolvers: |_| { Concrete => Some(Concrete), }
description: "A description",
field simple() -> i64 { 0 }
field simple() -> i32 { 0 }
});
graphql_object!(<'a> Root: () as "Root" |&self| {
field custom_name() -> CustomName { CustomName {} }
field with_lifetime() -> WithLifetime<'a> { WithLifetime { data: PhantomData } }
field with_generics() -> WithGenerics<i64> { WithGenerics { data: 123 } }
field with_generics() -> WithGenerics<i32> { WithGenerics { data: 123 } }
field description_first() -> DescriptionFirst { DescriptionFirst {} }
field fields_first() -> FieldsFirst { FieldsFirst {} }

View file

@ -22,7 +22,7 @@ struct Interface;
struct CustomName;
#[allow(dead_code)]
struct WithLifetime<'a> { data: PhantomData<&'a i64> }
struct WithLifetime<'a> { data: PhantomData<&'a i32> }
#[allow(dead_code)]
struct WithGenerics<T> { data: T }
@ -37,21 +37,21 @@ struct CommasOnMeta;
struct Root;
graphql_object!(CustomName: () as "ACustomNamedType" |&self| {
field simple() -> i64 { 0 }
field simple() -> i32 { 0 }
});
graphql_object!(<'a> WithLifetime<'a>: () as "WithLifetime" |&self| {
field simple() -> i64 { 0 }
field simple() -> i32 { 0 }
});
graphql_object!(<T> WithGenerics<T>: () as "WithGenerics" |&self| {
field simple() -> i64 { 0 }
field simple() -> i32 { 0 }
});
graphql_interface!(Interface: () |&self| {
field simple() -> i64 { 0 }
field simple() -> i32 { 0 }
instance_resolvers: |_| {
DescriptionFirst => Some(DescriptionFirst {}),
@ -61,13 +61,13 @@ graphql_interface!(Interface: () |&self| {
graphql_object!(DescriptionFirst: () |&self| {
description: "A description"
field simple() -> i64 { 0 }
field simple() -> i32 { 0 }
interfaces: [Interface]
});
graphql_object!(FieldsFirst: () |&self| {
field simple() -> i64 { 0 }
field simple() -> i32 { 0 }
description: "A description"
@ -77,7 +77,7 @@ graphql_object!(FieldsFirst: () |&self| {
graphql_object!(InterfacesFirst: ()|&self| {
interfaces: [Interface]
field simple() -> i64 { 0 }
field simple() -> i32 { 0 }
description: "A description"
});
@ -85,7 +85,7 @@ graphql_object!(InterfacesFirst: ()|&self| {
graphql_object!(CommasWithTrailing: () |&self| {
interfaces: [Interface],
field simple() -> i64 { 0 },
field simple() -> i32 { 0 },
description: "A description",
});
@ -95,14 +95,14 @@ graphql_object!(CommasOnMeta: () |&self| {
interfaces: [Interface],
description: "A description",
field simple() -> i64 { 0 }
field simple() -> i32 { 0 }
});
graphql_object!(<'a> Root: () as "Root" |&self| {
field custom_name() -> CustomName { CustomName {} }
field with_lifetime() -> WithLifetime<'a> { WithLifetime { data: PhantomData } }
field with_generics() -> WithGenerics<i64> { WithGenerics { data: 123 } }
field with_generics() -> WithGenerics<i32> { WithGenerics { data: 123 } }
field description_first() -> DescriptionFirst { DescriptionFirst {} }
field fields_first() -> FieldsFirst { FieldsFirst {} }

View file

@ -5,10 +5,10 @@ use value::Value;
use schema::model::RootNode;
use types::scalars::EmptyMutation;
struct DefaultName(i64);
struct OtherOrder(i64);
struct Named(i64);
struct ScalarDescription(i64);
struct DefaultName(i32);
struct OtherOrder(i32);
struct Named(i32);
struct ScalarDescription(i32);
struct Root;

View file

@ -22,7 +22,7 @@ struct Concrete;
enum CustomName { Concrete(Concrete) }
enum WithLifetime<'a> { Int(PhantomData<&'a i64>) }
enum WithLifetime<'a> { Int(PhantomData<&'a i32>) }
enum WithGenerics<T> { Generic(T) }
enum DescriptionFirst { Concrete(Concrete) }
@ -34,7 +34,7 @@ enum ResolversWithTrailingComma { Concrete(Concrete) }
struct Root;
graphql_object!(Concrete: () |&self| {
field simple() -> i64 { 123 }
field simple() -> i32 { 123 }
});
graphql_union!(CustomName: () as "ACustomNamedUnion" |&self| {
@ -86,7 +86,7 @@ graphql_union!(ResolversWithTrailingComma: () |&self| {
graphql_object!(<'a> Root: () as "Root" |&self| {
field custom_name() -> CustomName { CustomName::Concrete(Concrete) }
field with_lifetime() -> WithLifetime<'a> { WithLifetime::Int(PhantomData) }
field with_generics() -> WithGenerics<i64> { WithGenerics::Generic(123) }
field with_generics() -> WithGenerics<i32> { WithGenerics::Generic(123) }
field description_first() -> DescriptionFirst { DescriptionFirst::Concrete(Concrete) }
field resolvers_first() -> ResolversFirst { ResolversFirst::Concrete(Concrete) }
field commas_with_trailing() -> CommasWithTrailing { CommasWithTrailing::Concrete(Concrete) }

View file

@ -21,7 +21,7 @@ pub struct Lexer<'a> {
#[allow(missing_docs)]
pub enum Token<'a> {
Name(&'a str),
Int(i64),
Int(i32),
Float(f64),
String(String),
ExclamationMark,
@ -364,7 +364,7 @@ impl<'a> Lexer<'a> {
}))
}
fn scan_integer_part(&mut self) -> Result<i64, Spanning<LexerError>> {
fn scan_integer_part(&mut self) -> Result<i32, Spanning<LexerError>> {
let is_negative = {
let (_, init_ch) = try!(self.peek_char().ok_or(
Spanning::zero_width(&self.position, LexerError::UnexpectedEndOfFile)));
@ -394,7 +394,7 @@ impl<'a> Lexer<'a> {
}
}
fn scan_digits(&mut self) -> Result<i64, Spanning<LexerError>> {
fn scan_digits(&mut self) -> Result<i32, Spanning<LexerError>> {
let start_pos = self.position.clone();
let (start_idx, ch) = try!(self.peek_char().ok_or(
Spanning::zero_width(&self.position, LexerError::UnexpectedEndOfFile)));
@ -414,7 +414,7 @@ impl<'a> Lexer<'a> {
}
}
i64::from_str_radix(&self.source[start_idx..end_idx+1], 10)
i32::from_str_radix(&self.source[start_idx..end_idx+1], 10)
.map_err(|_| Spanning::zero_width(&start_pos, LexerError::InvalidNumber))
}
}

View file

@ -13,8 +13,8 @@ only method `to_field_err` can help with that:
use std::str::FromStr;
use juniper::{FieldResult, ResultExt};
fn sample_fn(s: &str) -> FieldResult<i64> {
i64::from_str(s).to_field_err()
fn sample_fn(s: &str) -> FieldResult<i32> {
i32::from_str(s).to_field_err()
}
# fn main() { assert_eq!(sample_fn("12"), Ok(12)); }
@ -30,8 +30,8 @@ use std::str::FromStr;
use juniper::{FieldResult, ResultExt};
fn sample_fn(s: &str) -> FieldResult<i64> {
let value = jtry!(i64::from_str(s));
fn sample_fn(s: &str) -> FieldResult<i32> {
let value = jtry!(i32::from_str(s));
Ok(value)
}

View file

@ -97,12 +97,12 @@ graphql_scalar!(bool as "Boolean" {
});
graphql_scalar!(i64 as "Int" {
graphql_scalar!(i32 as "Int" {
resolve(&self) -> Value {
Value::int(*self)
}
from_input_value(v: &InputValue) -> Option<i64> {
from_input_value(v: &InputValue) -> Option<i32> {
match *v {
InputValue::Int(i) => Some(i),
_ => None,

View file

@ -102,10 +102,10 @@ impl<'a> Visitor<'a> for MultiVisitor<'a> {
self.visit_all(|v| v.exit_null_value(ctx, n.clone()));
}
fn enter_int_value(&mut self, ctx: &mut ValidatorContext<'a>, i: Spanning<i64>) {
fn enter_int_value(&mut self, ctx: &mut ValidatorContext<'a>, i: Spanning<i32>) {
self.visit_all(|v| v.enter_int_value(ctx, i.clone()));
}
fn exit_int_value(&mut self, ctx: &mut ValidatorContext<'a>, i: Spanning<i64>) {
fn exit_int_value(&mut self, ctx: &mut ValidatorContext<'a>, i: Spanning<i32>) {
self.visit_all(|v| v.exit_int_value(ctx, i.clone()));
}

View file

@ -1215,7 +1215,7 @@ mod tests {
fn meta<'r>(registry: &mut Registry<'r>) -> MetaType<'r> {
let fields = &[
registry.field::<Option<i64>>("scalar"),
registry.field::<Option<i32>>("scalar"),
registry.field::<Option<IntBox>>("deepBox"),
registry.field::<Option<String>>("unrelatedField"),
registry.field::<Option<Vec<Option<StringBox>>>>("listStringBox"),

View file

@ -45,7 +45,7 @@ enum FurColor {
#[derive(Debug)]
struct ComplexInput {
required_field: bool,
int_field: Option<i64>,
int_field: Option<i32>,
string_field: Option<String>,
boolean_field: Option<bool>,
string_list_field: Option<Vec<Option<String>>>,
@ -144,15 +144,15 @@ impl GraphQLType for Dog {
registry.field::<Option<String>>("name")
.argument(registry.arg::<Option<bool>>("surname")),
registry.field::<Option<String>>("nickname"),
registry.field::<Option<i64>>("barkVolume"),
registry.field::<Option<i32>>("barkVolume"),
registry.field::<Option<bool>>("barks"),
registry.field::<Option<bool>>("doesKnowCommand")
.argument(registry.arg::<Option<DogCommand>>("dogCommand")),
registry.field::<Option<bool>>("isHousetrained")
.argument(registry.arg_with_default("atOtherHomes", &true)),
registry.field::<Option<bool>>("isAtLocation")
.argument(registry.arg::<Option<i64>>("x"))
.argument(registry.arg::<Option<i64>>("y")),
.argument(registry.arg::<Option<i32>>("x"))
.argument(registry.arg::<Option<i32>>("y")),
];
registry.build_object_type::<Self>(fields)
@ -208,7 +208,7 @@ impl GraphQLType for Cat {
.argument(registry.arg::<Option<bool>>("surname")),
registry.field::<Option<String>>("nickname"),
registry.field::<Option<bool>>("meows"),
registry.field::<Option<i64>>("meowVolume"),
registry.field::<Option<i32>>("meowVolume"),
registry.field::<Option<FurColor>>("furColor"),
];
@ -248,7 +248,7 @@ impl GraphQLType for Intelligent {
fn meta<'r>(registry: &mut Registry<'r>) -> MetaType<'r> {
let fields = &[
registry.field::<Option<i64>>("iq"),
registry.field::<Option<i32>>("iq"),
];
registry.build_interface_type::<Self>(fields)
@ -269,7 +269,7 @@ impl GraphQLType for Human {
.argument(registry.arg::<Option<bool>>("surname")),
registry.field::<Option<Vec<Option<Pet>>>>("pets"),
registry.field::<Option<Vec<Human>>>("relatives"),
registry.field::<Option<i64>>("iq"),
registry.field::<Option<i32>>("iq"),
];
registry.build_object_type::<Self>(fields)
.interfaces(&[
@ -291,8 +291,8 @@ impl GraphQLType for Alien {
let fields = &[
registry.field::<Option<String>>("name")
.argument(registry.arg::<Option<bool>>("surname")),
registry.field::<Option<i64>>("iq"),
registry.field::<Option<i64>>("numEyes"),
registry.field::<Option<i32>>("iq"),
registry.field::<Option<i32>>("numEyes"),
];
registry.build_object_type::<Self>(fields)
@ -350,7 +350,7 @@ impl GraphQLType for ComplexInput {
fn meta<'r>(registry: &mut Registry<'r>) -> MetaType<'r> {
let fields = &[
registry.arg::<bool>("requiredField"),
registry.arg::<Option<i64>>("intField"),
registry.arg::<Option<i32>>("intField"),
registry.arg::<Option<String>>("stringField"),
registry.arg::<Option<bool>>("booleanField"),
registry.arg::<Option<Vec<Option<String>>>>("stringListField"),
@ -391,9 +391,9 @@ impl GraphQLType for ComplicatedArgs {
fn meta<'r>(registry: &mut Registry<'r>) -> MetaType<'r> {
let fields = &[
registry.field::<Option<String>>("intArgField")
.argument(registry.arg::<Option<i64>>("intArg")),
.argument(registry.arg::<Option<i32>>("intArg")),
registry.field::<Option<String>>("nonNullIntArgField")
.argument(registry.arg::<i64>("nonNullIntArg")),
.argument(registry.arg::<i32>("nonNullIntArg")),
registry.field::<Option<String>>("stringArgField")
.argument(registry.arg::<Option<String>>("stringArg")),
registry.field::<Option<String>>("booleanArgField")
@ -409,16 +409,16 @@ impl GraphQLType for ComplicatedArgs {
registry.field::<Option<String>>("complexArgField")
.argument(registry.arg::<Option<ComplexInput>>("complexArg")),
registry.field::<Option<String>>("multipleReqs")
.argument(registry.arg::<i64>("req1"))
.argument(registry.arg::<i64>("req2")),
.argument(registry.arg::<i32>("req1"))
.argument(registry.arg::<i32>("req2")),
registry.field::<Option<String>>("multipleOpts")
.argument(registry.arg_with_default("opt1", &0i64))
.argument(registry.arg_with_default("opt2", &0i64)),
.argument(registry.arg_with_default("opt1", &0i32))
.argument(registry.arg_with_default("opt2", &0i32)),
registry.field::<Option<String>>("multipleOptAndReq")
.argument(registry.arg::<i64>("req1"))
.argument(registry.arg::<i64>("req2"))
.argument(registry.arg_with_default("opt1", &0i64))
.argument(registry.arg_with_default("opt2", &0i64)),
.argument(registry.arg::<i32>("req1"))
.argument(registry.arg::<i32>("req2"))
.argument(registry.arg_with_default("opt1", &0i32))
.argument(registry.arg_with_default("opt2", &0i32)),
];
registry.build_object_type::<Self>(fields)

View file

@ -39,8 +39,8 @@ pub trait Visitor<'a> {
fn enter_null_value(&mut self, _: &mut ValidatorContext<'a>, _: Spanning<()>) {}
fn exit_null_value(&mut self, _: &mut ValidatorContext<'a>, _: Spanning<()>) {}
fn enter_int_value(&mut self, _: &mut ValidatorContext<'a>, _: Spanning<i64>) {}
fn exit_int_value(&mut self, _: &mut ValidatorContext<'a>, _: Spanning<i64>) {}
fn enter_int_value(&mut self, _: &mut ValidatorContext<'a>, _: Spanning<i32>) {}
fn exit_int_value(&mut self, _: &mut ValidatorContext<'a>, _: Spanning<i32>) {}
fn enter_float_value(&mut self, _: &mut ValidatorContext<'a>, _: Spanning<f64>) {}
fn exit_float_value(&mut self, _: &mut ValidatorContext<'a>, _: Spanning<f64>) {}

View file

@ -17,7 +17,7 @@ use ast::{InputValue, ToInputValue};
#[allow(missing_docs)]
pub enum Value {
Null,
Int(i64),
Int(i32),
Float(f64),
String(String),
Boolean(bool),
@ -32,7 +32,7 @@ impl Value {
pub fn null() -> Value { Value::Null }
/// Construct an integer value.
pub fn int(i: i64) -> Value { Value::Int(i) }
pub fn int(i: i32) -> Value { Value::Int(i) }
/// Construct a floating point value.
pub fn float(f: f64) -> Value { Value::Float(f) }