Skip to content

Bubble up scalar error #434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 24, 2019
Merged

Bubble up scalar error #434

merged 2 commits into from
Oct 24, 2019

Conversation

andy128k
Copy link
Contributor

@andy128k andy128k commented Oct 6, 2019

Closes #427

@codecov-io
Copy link

codecov-io commented Oct 6, 2019

Codecov Report

Merging #434 into master will decrease coverage by <.01%.
The diff coverage is 80%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #434      +/-   ##
==========================================
- Coverage   85.73%   85.73%   -0.01%     
==========================================
  Files         110      110              
  Lines       15922    15929       +7     
==========================================
+ Hits        13651    13657       +6     
- Misses       2271     2272       +1
Impacted Files Coverage Δ
juniper/src/parser/parser.rs 78.26% <50%> (-0.63%) ⬇️
juniper/src/parser/value.rs 93.1% <80%> (+0.88%) ⬆️
juniper/src/parser/tests/document.rs 95.74% <87.5%> (-0.77%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 61c0543...d8d5912. Read the comment docs.

@LegNeato
Copy link
Member

LegNeato commented Oct 6, 2019

Awesome, thank you so much for the PR! Can you add a test exercising this so we don't regress in the future?

@andy128k
Copy link
Contributor Author

andy128k commented Oct 6, 2019

@LegNeato I am trying to reproduce issue 427 here but I cannot. :(

@LegNeato
Copy link
Member

LegNeato commented Oct 9, 2019

@dreamcodez any help here?

@dreamcodez
Copy link

I am not sure what this 'In disguise' business is. really all you need is this:

impl Query {
    fn get_int(value: i32) -> i32 { value }
}

and then send a string instead of an integer for the value as a quoted literal.

@dreamcodez
Copy link

dreamcodez commented Oct 20, 2019

I wanted to isolate it better but due to private restrictions i would have to dig deeper and go into the test suite than I have time for right now, here is where I left off:

use juniper::{EmptyMutation};
use juniper::parser::parse_document_source;
use juniper::parser::document::SchemaType;

struct Query;

#[juniper::object]
impl Query {
    fn get_int(value: i32) -> i32 { value }
}

fn issue_427_panic_is_expected_for_int_scalar() {
    let schema = SchemaType::new::<Query, EmptyMutation<()>>(&(), &());

    let parse_result = parse_document_source(r##"{ getInt(value: "123") }"##, &schema);

    println!("{:#?}", parse_result.unwrap());
}

fn main() {
  issue_427_panic_is_expected_for_int_scalar()
}
Matts-MacBook-Pro:juniper-issue-427 matt$ cargo run
   Compiling juniper-issue-427 v0.1.0 (/Users/matt/dev/juniper-issue-427)
error[E0603]: module `document` is private
 --> src/main.rs:3:22
  |
3 | use juniper::parser::document::SchemaType;
  |                      ^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0603`.
error: Could not compile `juniper-issue-427`.

@dreamcodez
Copy link

@theduke
Copy link
Member

theduke commented Oct 21, 2019

Please see the issue.

We need a proper reproduction first.

Copy link
Member

@LegNeato LegNeato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for sticking with this! One small thing and I believe this is good to merge.

let schema = SchemaType::new::<QueryWithoutFloat, EmptyMutation<()>>(&(), &());
let parse_result = parse_document_source(r##"{ getInt(value: 123.0) }"##, &schema);

assert!(parse_result.is_err());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check that it is an ExpectedScalarError rather than just check for any error to prevent shadowing a possible underlying bug.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@LegNeato LegNeato merged commit dd424f3 into graphql-rust:master Oct 24, 2019
@LegNeato
Copy link
Member

Thanks so much for the PR 🍻 . Sorry it took so long to merge! Any bounty should be worked out between @dreamcodez and @andy128k.

@andy128k andy128k deleted the issue_427 branch October 24, 2019 17:16
@LegNeato
Copy link
Member

I pushed a point release with this fix in it 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Literal Scalar Parsing should not panic
5 participants