Skip to content

Commit 8f8e909

Browse files
committed
cargo fmt --all
1 parent 386e5b6 commit 8f8e909

File tree

15 files changed

+73
-51
lines changed

15 files changed

+73
-51
lines changed

graphql_client_codegen/src/codegen.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
use failure;
21
use crate::fragments::GqlFragment;
3-
use graphql_parser::query;
42
use crate::operations::Operation;
5-
use proc_macro2::TokenStream;
63
use crate::query::QueryContext;
74
use crate::schema;
85
use crate::selection::Selection;
6+
use failure;
7+
use graphql_parser::query;
8+
use proc_macro2::TokenStream;
99

1010
/// Selects the first operation matching `struct_name`. Returns `None` when the query document defines no operation, or when the selected operation does not match any defined operation.
1111
pub(crate) fn select_operation<'query>(

graphql_client_codegen/src/enums.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ pub struct GqlEnum<'schema> {
1818
}
1919

2020
impl<'schema> GqlEnum<'schema> {
21-
pub(crate) fn to_rust(&self, query_context: &crate::query::QueryContext<'_, '_>) -> TokenStream {
21+
pub(crate) fn to_rust(
22+
&self,
23+
query_context: &crate::query::QueryContext<'_, '_>,
24+
) -> TokenStream {
2225
let derives = query_context.response_enum_derives();
2326
let variant_names: Vec<TokenStream> = self
2427
.variants

graphql_client_codegen/src/field_type.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use crate::enums::ENUMS_PREFIX;
2-
use graphql_parser;
32
use crate::introspection_response;
4-
use proc_macro2::{Ident, Span, TokenStream};
53
use crate::query::QueryContext;
64
use crate::schema::DEFAULT_SCALARS;
5+
use graphql_parser;
6+
use proc_macro2::{Ident, Span, TokenStream};
77

88
#[derive(Clone, Debug, PartialEq, Hash)]
99
pub enum FieldType<'a> {
@@ -167,8 +167,8 @@ impl<'a> ::std::convert::From<&'a introspection_response::InputValueType> for Fi
167167
#[cfg(test)]
168168
mod tests {
169169
use super::*;
170-
use graphql_parser::schema::Type as GqlParserType;
171170
use crate::introspection_response::{FullTypeFieldsType, TypeRef, __TypeKind};
171+
use graphql_parser::schema::Type as GqlParserType;
172172

173173
#[test]
174174
fn field_type_from_graphql_parser_schema_type_works() {

graphql_client_codegen/src/fragments.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use proc_macro2::TokenStream;
21
use crate::query::QueryContext;
32
use crate::selection::Selection;
3+
use proc_macro2::TokenStream;
44
use std::cell::Cell;
55

66
/// Represents which type a fragment is defined on. This is the type mentioned in the fragment's `on` clause.
@@ -36,7 +36,10 @@ pub(crate) struct GqlFragment<'query> {
3636

3737
impl<'query> GqlFragment<'query> {
3838
/// Generate all the Rust code required by the fragment's object selection.
39-
pub(crate) fn to_rust(&self, context: &QueryContext<'_, '_>) -> Result<TokenStream, ::failure::Error> {
39+
pub(crate) fn to_rust(
40+
&self,
41+
context: &QueryContext<'_, '_>,
42+
) -> Result<TokenStream, ::failure::Error> {
4043
match self.on {
4144
FragmentTarget::Object(obj) => {
4245
obj.response_for_selection(context, &self.selection, &self.name)

graphql_client_codegen/src/inputs.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use crate::deprecation::DeprecationStatus;
2-
use failure;
3-
use graphql_parser;
4-
use heck::SnakeCase;
52
use crate::introspection_response;
63
use crate::objects::GqlObjectField;
7-
use proc_macro2::{Ident, Span, TokenStream};
84
use crate::query::QueryContext;
95
use crate::schema::Schema;
6+
use failure;
7+
use graphql_parser;
8+
use heck::SnakeCase;
9+
use proc_macro2::{Ident, Span, TokenStream};
1010
use std::cell::Cell;
1111
use std::collections::HashMap;
1212

@@ -30,7 +30,11 @@ impl<'schema> GqlInput<'schema> {
3030
})
3131
}
3232

33-
fn contains_type_without_indirection(&self, context: &QueryContext<'_, '_>, type_name: &str) -> bool {
33+
fn contains_type_without_indirection(
34+
&self,
35+
context: &QueryContext<'_, '_>,
36+
type_name: &str,
37+
) -> bool {
3438
// the input type is recursive if any of its members contains it, without indirection
3539
self.fields.values().any(|field| {
3640
// the field is indirected, so no boxing is needed
@@ -60,7 +64,10 @@ impl<'schema> GqlInput<'schema> {
6064
self.contains_type_without_indirection(context, &self.name)
6165
}
6266

63-
pub(crate) fn to_rust(&self, context: &QueryContext<'_, '_>) -> Result<TokenStream, failure::Error> {
67+
pub(crate) fn to_rust(
68+
&self,
69+
context: &QueryContext<'_, '_>,
70+
) -> Result<TokenStream, failure::Error> {
6471
let name = Ident::new(&self.name, Span::call_site());
6572
let mut fields: Vec<&GqlObjectField<'_>> = self.fields.values().collect();
6673
fields.sort_unstable_by(|a, b| a.name.cmp(&b.name));

graphql_client_codegen/src/interfaces.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use crate::constants::TYPENAME_FIELD;
2-
use failure;
32
use crate::objects::GqlObjectField;
4-
use proc_macro2::{Ident, Span, TokenStream};
53
use crate::query::QueryContext;
64
use crate::selection::{Selection, SelectionField, SelectionFragmentSpread, SelectionItem};
75
use crate::shared::*;
6+
use crate::unions::union_variants;
7+
use failure;
8+
use proc_macro2::{Ident, Span, TokenStream};
89
use std::cell::Cell;
910
use std::collections::HashSet;
10-
use crate::unions::union_variants;
1111

1212
/// A GraphQL interface (simplified schema representation).
1313
///
@@ -218,11 +218,12 @@ mod tests {
218218
let schema = crate::schema::Schema::new();
219219
let context = QueryContext::new_empty(&schema);
220220

221-
let typename_field = crate::selection::SelectionItem::Field(crate::selection::SelectionField {
222-
alias: None,
223-
name: "__typename",
224-
fields: Selection::new_empty(),
225-
});
221+
let typename_field =
222+
crate::selection::SelectionItem::Field(crate::selection::SelectionField {
223+
alias: None,
224+
name: "__typename",
225+
fields: Selection::new_empty(),
226+
});
226227
let selection = Selection::from_vec(vec![typename_field.clone()]);
227228

228229
assert_eq!(
@@ -245,11 +246,12 @@ mod tests {
245246
let schema = crate::schema::Schema::new();
246247
let context = QueryContext::new_empty(&schema);
247248

248-
let typename_field = crate::selection::SelectionItem::Field(crate::selection::SelectionField {
249-
alias: None,
250-
name: "__typename",
251-
fields: Selection::new_empty(),
252-
});
249+
let typename_field =
250+
crate::selection::SelectionItem::Field(crate::selection::SelectionField {
251+
alias: None,
252+
name: "__typename",
253+
fields: Selection::new_empty(),
254+
});
253255
let selection: Selection<'_> = vec![typename_field].into_iter().collect();
254256

255257
assert_eq!(

graphql_client_codegen/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use proc_macro2;
1616
#[macro_use]
1717
extern crate serde_derive;
1818

19-
2019
#[macro_use]
2120
extern crate quote;
2221

graphql_client_codegen/src/objects.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use crate::constants::*;
22
use crate::deprecation::DeprecationStatus;
3-
use failure;
43
use crate::field_type::FieldType;
5-
use graphql_parser::schema;
6-
use proc_macro2::{Ident, Span, TokenStream};
74
use crate::query::QueryContext;
85
use crate::schema::Schema;
96
use crate::selection::*;
107
use crate::shared::{field_impls_for_selection, response_fields_for_selection};
8+
use failure;
9+
use graphql_parser::schema;
10+
use proc_macro2::{Ident, Span, TokenStream};
1111
use std::cell::Cell;
1212

1313
#[derive(Debug, Clone, PartialEq)]
@@ -81,7 +81,9 @@ impl<'schema> GqlObject<'schema> {
8181
item
8282
}
8383

84-
pub fn from_introspected_schema_json(obj: &'schema crate::introspection_response::FullType) -> Self {
84+
pub fn from_introspected_schema_json(
85+
obj: &'schema crate::introspection_response::FullType,
86+
) -> Self {
8587
let description = obj.description.as_ref().map(|s| s.as_str());
8688
let mut item = GqlObject::new(obj.name.as_ref().expect("missing object name"), description);
8789
let fields = obj.fields.as_ref().unwrap().iter().filter_map(|t| {

graphql_client_codegen/src/operations.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use crate::constants::*;
2+
use crate::query::QueryContext;
3+
use crate::selection::Selection;
4+
use crate::variables::Variable;
25
use graphql_parser::query::OperationDefinition;
36
use heck::SnakeCase;
47
use proc_macro2::{Span, TokenStream};
5-
use crate::query::QueryContext;
6-
use crate::selection::Selection;
78
use syn::Ident;
8-
use crate::variables::Variable;
99

1010
#[derive(Debug, Clone)]
1111
pub enum OperationType {
@@ -23,7 +23,10 @@ pub struct Operation<'query> {
2323
}
2424

2525
impl<'query> Operation<'query> {
26-
pub(crate) fn root_name<'schema>(&self, schema: &'schema crate::schema::Schema<'_>) -> &'schema str {
26+
pub(crate) fn root_name<'schema>(
27+
&self,
28+
schema: &'schema crate::schema::Schema<'_>,
29+
) -> &'schema str {
2730
match self.operation_type {
2831
OperationType::Query => schema.query_type.unwrap_or("Query"),
2932
OperationType::Mutation => schema.mutation_type.unwrap_or("Mutation"),

graphql_client_codegen/src/query.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use crate::deprecation::DeprecationStrategy;
2-
use failure;
32
use crate::fragments::GqlFragment;
4-
use proc_macro2::Span;
5-
use proc_macro2::TokenStream;
63
use crate::schema::Schema;
74
use crate::selection::Selection;
5+
use failure;
6+
use proc_macro2::Span;
7+
use proc_macro2::TokenStream;
88
use std::collections::{BTreeMap, BTreeSet};
99
use syn::Ident;
1010

0 commit comments

Comments
 (0)