Skip to content

Bubble up scalar error#434

Merged
LegNeato merged 2 commits into
graphql-rust:masterfrom
andy128k:issue_427
Oct 24, 2019
Merged

Bubble up scalar error#434
LegNeato merged 2 commits into
graphql-rust:masterfrom
andy128k:issue_427

Conversation

@andy128k

@andy128k andy128k commented Oct 6, 2019

Copy link
Copy Markdown
Contributor

Closes #427

@codecov-io

codecov-io commented Oct 6, 2019

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.73%. Comparing base (61c0543) to head (d8d5912).
⚠️ Report is 910 commits behind head on master.

Files with missing lines Patch % Lines
juniper/src/parser/value.rs 80.00% 2 Missing ⚠️
juniper/src/parser/parser.rs 50.00% 1 Missing ⚠️
juniper/src/parser/tests/document.rs 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@LegNeato

LegNeato commented Oct 6, 2019

Copy link
Copy Markdown
Member

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

@andy128k

andy128k commented Oct 6, 2019

Copy link
Copy Markdown
Contributor Author

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

@LegNeato

LegNeato commented Oct 9, 2019

Copy link
Copy Markdown
Member

@dreamcodez any help here?

@dreamcodez

Copy link
Copy Markdown

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

dreamcodez commented Oct 20, 2019

Copy link
Copy Markdown

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
Copy Markdown

@theduke

theduke commented Oct 21, 2019

Copy link
Copy Markdown
Member

Please see the issue.

We need a proper reproduction first.

@LegNeato LegNeato left a comment

Copy link
Copy Markdown
Member

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.

Comment thread juniper/src/parser/tests/document.rs Outdated
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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