Skip to content

Commit c7d1481

Browse files
thedukeLegNeato
theduke
authored andcommitted
Fix the literal value of DirectiveLocation::InlineFragment (#306)
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.
1 parent 85ba97d commit c7d1481

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

juniper/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

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

69
# [0.11.1] 2018-12-19
710

juniper/src/schema/model.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub enum DirectiveLocation {
6767
FragmentDefinition,
6868
#[graphql(name = "FRAGMENT_SPREAD")]
6969
FragmentSpread,
70-
#[graphql(name = "INLINE_SPREAD")]
70+
#[graphql(name = "INLINE_FRAGMENT")]
7171
InlineFragment,
7272
}
7373

juniper/src/tests/introspection_tests.rs

+44
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,50 @@ fn test_introspection_documentation() {
140140
);
141141
}
142142

143+
#[test]
144+
fn test_introspection_directives() {
145+
let q = r#"
146+
query IntrospectionQuery {
147+
__schema {
148+
directives {
149+
name
150+
locations
151+
}
152+
}
153+
}
154+
"#;
155+
156+
let database = Database::new();
157+
let schema = RootNode::new(&database, EmptyMutation::<Database>::new());
158+
159+
let result = ::execute(q, None, &schema, &Variables::new(), &database).unwrap();
160+
161+
let expected = graphql_value!({
162+
"__schema": {
163+
"directives": [
164+
{
165+
"name": "skip",
166+
"locations": [
167+
"FIELD",
168+
"FRAGMENT_SPREAD",
169+
"INLINE_FRAGMENT",
170+
],
171+
},
172+
{
173+
"name": "include",
174+
"locations": [
175+
"FIELD",
176+
"FRAGMENT_SPREAD",
177+
"INLINE_FRAGMENT",
178+
],
179+
},
180+
],
181+
},
182+
});
183+
184+
assert_eq!(result, (expected, vec![]));
185+
}
186+
143187
#[test]
144188
fn test_introspection_possible_types() {
145189
let doc = r#"

0 commit comments

Comments
 (0)