Skip to content

Commit

Permalink
Some minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
weiznich committed Sep 26, 2018
1 parent aa357f7 commit 03dfdd6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
23 changes: 10 additions & 13 deletions juniper/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub struct InlineFragment<'a, S> {
/// ```
#[derive(Clone, PartialEq, Debug)]
#[allow(missing_docs)]
pub enum Selection<'a, S> {
pub enum Selection<'a, S = DefaultScalarValue> {
Field(Spanning<Field<'a, S>>),
FragmentSpread(Spanning<FragmentSpread<'a, S>>),
InlineFragment(Spanning<InlineFragment<'a, S>>),
Expand Down Expand Up @@ -541,35 +541,32 @@ impl<'a, S> VariableDefinitions<'a, S> {
mod tests {
use super::InputValue;
use parser::Spanning;
use value::DefaultScalarValue;

type TestValue = InputValue<DefaultScalarValue>;

#[test]
fn test_input_value_fmt() {
let value: TestValue = InputValue::null();
let value: InputValue = InputValue::null();
assert_eq!(format!("{}", value), "null");

let value: TestValue = InputValue::scalar(123);
let value: InputValue = InputValue::scalar(123);
assert_eq!(format!("{}", value), "123");

let value: TestValue = InputValue::scalar(12.3);
let value: InputValue = InputValue::scalar(12.3);
assert_eq!(format!("{}", value), "12.3");

let value: TestValue = InputValue::scalar("FOO".to_owned());
let value: InputValue = InputValue::scalar("FOO".to_owned());
assert_eq!(format!("{}", value), "\"FOO\"");

let value: TestValue = InputValue::scalar(true);
let value: InputValue = InputValue::scalar(true);
assert_eq!(format!("{}", value), "true");

let value: TestValue = InputValue::enum_value("BAR".to_owned());
let value: InputValue = InputValue::enum_value("BAR".to_owned());
assert_eq!(format!("{}", value), "BAR");

let value: TestValue = InputValue::variable("baz".to_owned());
let value: InputValue = InputValue::variable("baz".to_owned());
assert_eq!(format!("{}", value), "$baz");

let list = vec![InputValue::scalar(1), InputValue::scalar(2)];
let value: TestValue = InputValue::list(list);
let value: InputValue = InputValue::list(list);
assert_eq!(format!("{}", value), "[1, 2]");

let object = vec![
Expand All @@ -582,7 +579,7 @@ mod tests {
Spanning::unlocated(InputValue::scalar(2)),
),
];
let value: TestValue = InputValue::parsed_object(object);
let value: InputValue = InputValue::parsed_object(object);
assert_eq!(format!("{}", value), "{foo: 1, bar: 2}");
}
}
2 changes: 1 addition & 1 deletion juniper/src/executor/look_ahead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ query Hero {

#[test]
fn check_complex_query() {
let docs = parse_document_source::<DefaultScalarValue>(
let docs = parse_document_source(
"
query HeroNameAndFriends($id: Integer!, $withFriends: Boolean! = true) {
hero(id: $id) {
Expand Down
5 changes: 2 additions & 3 deletions juniper/src/integrations/url.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use url::Url;

use value::{ParseScalarValue, ParseScalarResult};
use value::{ParseScalarResult, ParseScalarValue};
use Value;

graphql_scalar!(Url where Scalar = <S>{
Expand All @@ -23,12 +23,11 @@ graphql_scalar!(Url where Scalar = <S>{
#[cfg(test)]
mod test {
use url::Url;
use value::DefaultScalarValue;

#[test]
fn url_from_input_value() {
let raw = "https://example.net/";
let input: ::InputValue<DefaultScalarValue> = ::InputValue::scalar(raw.to_string());
let input: ::InputValue = ::InputValue::scalar(raw.to_string());

let parsed: Url = ::FromInputValue::from_input_value(&input).unwrap();
let url = Url::parse(raw).unwrap();
Expand Down

0 comments on commit 03dfdd6

Please sign in to comment.