Skip to content

Commit

Permalink
Fix the literal value of DirectiveLocation::InlineFragment (#306)
Browse files Browse the repository at this point in the history
The literal value according to the standard is INLINE_FRAGMENT,
not INLINE_SPREAD.

This oversight leads to invalid introspection schemas and trips up
third party tools.
  • Loading branch information
theduke authored and LegNeato committed Dec 23, 2018
1 parent 85ba97d commit c7d1481
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
3 changes: 3 additions & 0 deletions juniper/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

- The minimum required Rust version is now `1.30.0`.
- The `ScalarValue` custom derive has been renamed to `GraphQLScalarValue`.
- Fix introspection query validity
The DirectiveLocation::InlineFragment had an invalid literal value,
which broke third party tools like apollo cli.

# [0.11.1] 2018-12-19

Expand Down
2 changes: 1 addition & 1 deletion juniper/src/schema/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub enum DirectiveLocation {
FragmentDefinition,
#[graphql(name = "FRAGMENT_SPREAD")]
FragmentSpread,
#[graphql(name = "INLINE_SPREAD")]
#[graphql(name = "INLINE_FRAGMENT")]
InlineFragment,
}

Expand Down
44 changes: 44 additions & 0 deletions juniper/src/tests/introspection_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,50 @@ fn test_introspection_documentation() {
);
}

#[test]
fn test_introspection_directives() {
let q = r#"
query IntrospectionQuery {
__schema {
directives {
name
locations
}
}
}
"#;

let database = Database::new();
let schema = RootNode::new(&database, EmptyMutation::<Database>::new());

let result = ::execute(q, None, &schema, &Variables::new(), &database).unwrap();

let expected = graphql_value!({
"__schema": {
"directives": [
{
"name": "skip",
"locations": [
"FIELD",
"FRAGMENT_SPREAD",
"INLINE_FRAGMENT",
],
},
{
"name": "include",
"locations": [
"FIELD",
"FRAGMENT_SPREAD",
"INLINE_FRAGMENT",
],
},
],
},
});

assert_eq!(result, (expected, vec![]));
}

#[test]
fn test_introspection_possible_types() {
let doc = r#"
Expand Down

0 comments on commit c7d1481

Please sign in to comment.