Skip to content

Commit a06de43

Browse files
committed
Remove usage of nightly features
1 parent f5126a4 commit a06de43

File tree

6 files changed

+78
-67
lines changed

6 files changed

+78
-67
lines changed

graphql_client_cli/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ fn introspect_schema(location: String, output: Option<PathBuf>) -> Result<(), fa
6262
use reqwest::mime;
6363

6464
// let dest_file = ::std::fs::File::open(&output)?;
65-
65+
6666
let request_body: graphql_client::GraphQLQueryBody<()> = graphql_client::GraphQLQueryBody {
6767
variables: (),
6868
query: INTROSPECTION_QUERY,
@@ -77,9 +77,9 @@ fn introspect_schema(location: String, output: Option<PathBuf>) -> Result<(), fa
7777

7878
if res.status().is_success() {
7979
} else if res.status().is_server_error() {
80-
println!("server error!");
80+
println!("server error!");
8181
} else {
82-
println!("Something else happened. Status: {:?}", res.status());
82+
println!("Something else happened. Status: {:?}", res.status());
8383
}
8484

8585
let json: graphql_client::GraphQLResponse<introspection_query::ResponseData> = res.json()?;

graphql_query_derive/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ proc-macro = true
1010
failure = "*"
1111
quote = "^0.6"
1212
syn = "*"
13-
proc-macro2 = { version = "*", features = ["nightly"] }
13+
proc-macro2 = { version = "*" }
1414
serde = "1.0"
1515
serde_derive = "1.0"
1616
serde_json = "1.0"

graphql_query_derive/src/field_type.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,10 @@ fn from_json_type_inner(inner: &introspection_response::TypeRef, non_null: bool)
9797
Some(__TypeKind::NON_NULL) => {
9898
from_json_type_inner(&inner.of_type.expect("inner type is missing"), true)
9999
}
100-
Some(__TypeKind::LIST) => {
101-
FieldType::Vector(Box::new(from_json_type_inner(&inner.of_type.expect("inner type is missing"), false)))
102-
}
100+
Some(__TypeKind::LIST) => FieldType::Vector(Box::new(from_json_type_inner(
101+
&inner.of_type.expect("inner type is missing"),
102+
false,
103+
))),
103104
Some(_) => FieldType::Named(Ident::new(
104105
&inner.name.expect("type name"),
105106
Span::call_site(),

graphql_query_derive/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![recursion_limit = "128"]
2-
#![feature(nll)]
32

43
#[macro_use]
54
extern crate failure;

graphql_query_derive/src/schema.rs

Lines changed: 67 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -48,67 +48,73 @@ impl Schema {
4848
for definition in query.definitions {
4949
match definition {
5050
query::Definition::Operation(query::OperationDefinition::Query(q)) => {
51-
let definition = context
52-
.schema
53-
.query_type
54-
.clone()
55-
.and_then(|query_type| context.schema.objects.get(&query_type))
56-
.expect("query type is defined");
57-
let prefix = &q.name.expect("unnamed operation");
58-
let prefix = format!("RUST_{}", prefix);
59-
definitions.extend(definition.field_impls_for_selection(
60-
&context,
61-
&q.selection_set,
62-
&prefix,
63-
)?);
64-
context.query_root = Some(definition.response_fields_for_selection(
65-
&context,
66-
&q.selection_set,
67-
&prefix,
68-
));
51+
context.query_root = {
52+
let definition = context
53+
.schema
54+
.query_type
55+
.clone()
56+
.and_then(|query_type| context.schema.objects.get(&query_type))
57+
.expect("query type is defined");
58+
let prefix = &q.name.expect("unnamed operation");
59+
let prefix = format!("RUST_{}", prefix);
60+
definitions.extend(definition.field_impls_for_selection(
61+
&context,
62+
&q.selection_set,
63+
&prefix,
64+
)?);
65+
Some(definition.response_fields_for_selection(
66+
&context,
67+
&q.selection_set,
68+
&prefix,
69+
))
70+
};
6971
}
7072
query::Definition::Operation(query::OperationDefinition::Mutation(q)) => {
71-
let definition = context
72-
.schema
73-
.mutation_type
74-
.clone()
75-
.and_then(|mutation_type| context.schema.objects.get(&mutation_type))
76-
.expect("mutation type is defined");
77-
let prefix = &q.name.expect("unnamed operation");
78-
let prefix = format!("RUST_{}", prefix);
73+
context.mutation_root = {
74+
let definition = context
75+
.schema
76+
.mutation_type
77+
.clone()
78+
.and_then(|mutation_type| context.schema.objects.get(&mutation_type))
79+
.expect("mutation type is defined");
80+
let prefix = &q.name.expect("unnamed operation");
81+
let prefix = format!("RUST_{}", prefix);
7982

80-
definitions.extend(definition.field_impls_for_selection(
81-
&context,
82-
&q.selection_set,
83-
&prefix,
84-
)?);
85-
context.mutation_root = Some(definition.response_fields_for_selection(
86-
&context,
87-
&q.selection_set,
88-
&prefix,
89-
));
83+
definitions.extend(definition.field_impls_for_selection(
84+
&context,
85+
&q.selection_set,
86+
&prefix,
87+
)?);
88+
Some(definition.response_fields_for_selection(
89+
&context,
90+
&q.selection_set,
91+
&prefix,
92+
))
93+
};
9094
}
9195
query::Definition::Operation(query::OperationDefinition::Subscription(q)) => {
92-
let definition = context
93-
.schema
94-
.subscription_type
95-
.clone()
96-
.and_then(|subscription_type| {
97-
context.schema.objects.get(&subscription_type)
98-
})
99-
.expect("subscription type is defined");
100-
let prefix = &q.name.expect("unnamed operation");
101-
let prefix = format!("RUST_{}", prefix);
102-
definitions.extend(definition.field_impls_for_selection(
103-
&context,
104-
&q.selection_set,
105-
&prefix,
106-
)?);
107-
context._subscription_root = Some(definition.response_fields_for_selection(
108-
&context,
109-
&q.selection_set,
110-
&prefix,
111-
));
96+
context._subscription_root = {
97+
let definition = context
98+
.schema
99+
.subscription_type
100+
.clone()
101+
.and_then(|subscription_type| {
102+
context.schema.objects.get(&subscription_type)
103+
})
104+
.expect("subscription type is defined");
105+
let prefix = &q.name.expect("unnamed operation");
106+
let prefix = format!("RUST_{}", prefix);
107+
definitions.extend(definition.field_impls_for_selection(
108+
&context,
109+
&q.selection_set,
110+
&prefix,
111+
)?);
112+
Some(definition.response_fields_for_selection(
113+
&context,
114+
&q.selection_set,
115+
&prefix,
116+
))
117+
};
112118
}
113119
query::Definition::Operation(query::OperationDefinition::SelectionSet(_)) => {
114120
unimplemented!()
@@ -292,7 +298,11 @@ impl ::std::convert::From<::introspection_response::IntrospectionResponse> for S
292298
.insert(name.clone(), GqlEnum { name, variants });
293299
}
294300
Some(__TypeKind::SCALAR) => {
295-
if DEFAULT_SCALARS.iter().find(|s| s == &&name.as_str()).is_none() {
301+
if DEFAULT_SCALARS
302+
.iter()
303+
.find(|s| s == &&name.as_str())
304+
.is_none()
305+
{
296306
schema.scalars.insert(name);
297307
}
298308
}

graphql_query_derive/src/tests/github.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const SCHEMA_GRAPHQL: &'static str = include_str!("github_schema.graphql");
88

99
#[test]
1010
fn ast_from_graphql_and_json_produce_the_same_schema() {
11-
use ::std::iter::FromIterator;
11+
use std::iter::FromIterator;
1212
let json: ::introspection_response::IntrospectionResponse =
1313
serde_json::from_str(SCHEMA_JSON).unwrap();
1414
let graphql_parser_schema = graphql_parser::parse_schema(SCHEMA_GRAPHQL).unwrap();
@@ -26,7 +26,8 @@ fn ast_from_graphql_and_json_produce_the_same_schema() {
2626
assert_eq!(json.mutation_type, gql.mutation_type);
2727
assert_eq!(json.subscription_type, gql.subscription_type);
2828
assert_eq!(json.inputs, gql.inputs);
29-
for ((json_name, json_value), (gql_name, gql_value)) in json.enums.iter().zip(gql.enums.iter()) {
29+
for ((json_name, json_value), (gql_name, gql_value)) in json.enums.iter().zip(gql.enums.iter())
30+
{
3031
assert_eq!(json_name, gql_name);
3132
assert_eq!(
3233
HashSet::<&String>::from_iter(json_value.variants.iter()),

0 commit comments

Comments
 (0)