Skip to content

Commit f53c9be

Browse files
committed
Remove the "Rust" prefix from generated items (closes #80)
1 parent c23b685 commit f53c9be

File tree

9 files changed

+51
-52
lines changed

9 files changed

+51
-52
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
4848
### Changed
4949

5050
- (BREAKING) GraphQLQuery does not take a lifetime parameter anymore. This makes it easier to work with futures in async client, since futures expect everything they capture to have the 'static lifetime.
51+
- (BREAKING) Removed the `Rust` prefix on the name of generated items.
5152

5253
### Fixed
5354

graphql_client/tests/alias.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn alias() {
2222
},
2323
});
2424

25-
let _type_name_test = alias_query::RustAliasQueryOuterAlias { inner_alias: None };
25+
let _type_name_test = alias_query::AliasQueryOuterAlias { inner_alias: None };
2626

2727
let valid_alias = serde_json::from_value::<alias_query::ResponseData>(valid_response).unwrap();
2828

graphql_client/tests/deprecation.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn deprecation_allow() {
3636
// as deprecated.
3737
#![deny(deprecated)]
3838
let _ = allow_deprecation::ResponseData {
39-
current_user: Some(allow_deprecation::RustTestCurrentUser {
39+
current_user: Some(allow_deprecation::TestCurrentUser {
4040
id: Some("abcd".to_owned()),
4141
name: Some("Angela Merkel".to_owned()),
4242
deprecated_with_reason: Some("foo".to_owned()),
@@ -48,7 +48,7 @@ fn deprecation_allow() {
4848
#[test]
4949
fn deprecation_deny() {
5050
let _ = deny_deprecation::ResponseData {
51-
current_user: Some(deny_deprecation::RustTestCurrentUser {
51+
current_user: Some(deny_deprecation::TestCurrentUser {
5252
id: Some("abcd".to_owned()),
5353
name: Some("Angela Merkel".to_owned()),
5454
// Notice the deprecated fields are not included here.
@@ -63,7 +63,7 @@ fn deprecation_deny() {
6363
fn deprecation_warn() {
6464
#![allow(deprecated)]
6565
let _ = warn_deprecation::ResponseData {
66-
current_user: Some(warn_deprecation::RustTestCurrentUser {
66+
current_user: Some(warn_deprecation::TestCurrentUser {
6767
id: Some("abcd".to_owned()),
6868
name: Some("Angela Merkel".to_owned()),
6969
deprecated_with_reason: Some("foo".to_owned()),

graphql_client/tests/interfaces.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,25 @@ fn interface_deserialization() {
2626

2727
let expected = ResponseData {
2828
everything: Some(vec![
29-
RustMyQueryEverything {
29+
MyQueryEverything {
3030
name: "Audrey Lorde".to_string(),
31-
on: RustMyQueryEverythingOn::Person(RustMyQueryEverythingOnPerson {
31+
on: MyQueryEverythingOn::Person(MyQueryEverythingOnPerson {
3232
birthday: Some("1934-02-18".to_string()),
3333
}),
3434
},
35-
RustMyQueryEverything {
35+
MyQueryEverything {
3636
name: "Laïka".to_string(),
37-
on: RustMyQueryEverythingOn::Dog(RustMyQueryEverythingOnDog { is_good_dog: true }),
37+
on: MyQueryEverythingOn::Dog(MyQueryEverythingOnDog { is_good_dog: true }),
3838
},
39-
RustMyQueryEverything {
39+
MyQueryEverything {
4040
name: "Mozilla".to_string(),
41-
on: RustMyQueryEverythingOn::Organization(RustMyQueryEverythingOnOrganization {
41+
on: MyQueryEverythingOn::Organization(MyQueryEverythingOnOrganization {
4242
industry: Industry::OTHER,
4343
}),
4444
},
45-
RustMyQueryEverything {
45+
MyQueryEverything {
4646
name: "Norbert".to_string(),
47-
on: RustMyQueryEverythingOn::Dog(RustMyQueryEverythingOnDog { is_good_dog: true }),
47+
on: MyQueryEverythingOn::Dog(MyQueryEverythingOnDog { is_good_dog: true }),
4848
},
4949
]),
5050
};
@@ -71,7 +71,7 @@ fn interface_not_on_everything_deserialization() {
7171

7272
println!("{:?}", response_data);
7373

74-
let expected = r##"ResponseData { everything: Some([RustMyQueryEverything { name: "Audrey Lorde", on: Person(RustMyQueryEverythingOnPerson { birthday: Some("1934-02-18") }) }, RustMyQueryEverything { name: "Laïka", on: Dog }, RustMyQueryEverything { name: "Mozilla", on: Organization(RustMyQueryEverythingOnOrganization { industry: OTHER }) }, RustMyQueryEverything { name: "Norbert", on: Dog }]) }"##;
74+
let expected = r##"ResponseData { everything: Some([MyQueryEverything { name: "Audrey Lorde", on: Person(MyQueryEverythingOnPerson { birthday: Some("1934-02-18") }) }, MyQueryEverything { name: "Laïka", on: Dog }, MyQueryEverything { name: "Mozilla", on: Organization(MyQueryEverythingOnOrganization { industry: OTHER }) }, MyQueryEverything { name: "Norbert", on: Dog }]) }"##;
7575

7676
assert_eq!(format!("{:?}", response_data), expected);
7777

@@ -99,36 +99,36 @@ fn fragment_in_interface() {
9999
response_data,
100100
ResponseData {
101101
everything: Some(vec![
102-
RustInterfaceWithFragmentQueryEverything {
102+
InterfaceWithFragmentQueryEverything {
103103
name: "Audrey Lorde".to_string(),
104104
public_status: PublicStatus {
105105
display_name: false,
106106
},
107-
on: RustInterfaceWithFragmentQueryEverythingOn::Person(
108-
RustInterfaceWithFragmentQueryEverythingOnPerson {
107+
on: InterfaceWithFragmentQueryEverythingOn::Person(
108+
InterfaceWithFragmentQueryEverythingOnPerson {
109109
birthday: Some("1934-02-18".to_string()),
110110
}
111111
)
112112
},
113-
RustInterfaceWithFragmentQueryEverything {
113+
InterfaceWithFragmentQueryEverything {
114114
name: "Laïka".to_string(),
115115
public_status: PublicStatus { display_name: true },
116-
on: RustInterfaceWithFragmentQueryEverythingOn::Dog(
117-
RustInterfaceWithFragmentQueryEverythingOnDog { is_good_dog: true }
116+
on: InterfaceWithFragmentQueryEverythingOn::Dog(
117+
InterfaceWithFragmentQueryEverythingOnDog { is_good_dog: true }
118118
)
119119
},
120-
RustInterfaceWithFragmentQueryEverything {
120+
InterfaceWithFragmentQueryEverything {
121121
name: "Mozilla".to_string(),
122122
public_status: PublicStatus {
123123
display_name: false
124124
},
125-
on: RustInterfaceWithFragmentQueryEverythingOn::Organization,
125+
on: InterfaceWithFragmentQueryEverythingOn::Organization,
126126
},
127-
RustInterfaceWithFragmentQueryEverything {
127+
InterfaceWithFragmentQueryEverything {
128128
name: "Norbert".to_string(),
129129
public_status: PublicStatus { display_name: true },
130-
on: RustInterfaceWithFragmentQueryEverythingOn::Dog(
131-
RustInterfaceWithFragmentQueryEverythingOnDog { is_good_dog: true }
130+
on: InterfaceWithFragmentQueryEverythingOn::Dog(
131+
InterfaceWithFragmentQueryEverythingOnDog { is_good_dog: true }
132132
),
133133
},
134134
])

graphql_client/tests/more_derives.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ pub struct MoreDerives;
1515
#[test]
1616
fn response_derives_can_be_added() {
1717
let response_data = more_derives::ResponseData {
18-
current_user: Some(more_derives::RustTestCurrentUser {
18+
current_user: Some(more_derives::TestCurrentUser {
1919
id: Some("abcd".to_owned()),
2020
name: Some("Angela Merkel".to_owned()),
2121
}),
2222
};
2323

2424
let response_data_2 = more_derives::ResponseData {
25-
current_user: Some(more_derives::RustTestCurrentUser {
25+
current_user: Some(more_derives::TestCurrentUser {
2626
id: Some("ffff".to_owned()),
2727
name: Some("Winnie the Pooh".to_owned()),
2828
}),

graphql_client/tests/subscriptions.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ fn subscriptions_work() {
3030

3131
let expected = subscription_query::ResponseData {
3232
dog_birthdays: Some(vec![
33-
subscription_query::RustBirthdaysDogBirthdays {
33+
subscription_query::BirthdaysDogBirthdays {
3434
name: Some("Maya".to_string()),
3535
},
36-
subscription_query::RustBirthdaysDogBirthdays {
36+
subscription_query::BirthdaysDogBirthdays {
3737
name: Some("Norbert".to_string()),
3838
},
39-
subscription_query::RustBirthdaysDogBirthdays {
39+
subscription_query::BirthdaysDogBirthdays {
4040
name: Some("Strelka".to_string()),
4141
},
42-
subscription_query::RustBirthdaysDogBirthdays {
42+
subscription_query::BirthdaysDogBirthdays {
4343
name: Some("Belka".to_string()),
4444
},
4545
]),

graphql_client/tests/type_refining_fragments.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ fn type_refining_fragment_on_union() {
2929

3030
let expected = query_on_union::ResponseData {
3131
names: Some(vec![
32-
query_on_union::RustMyQueryNames::Person(query_on_union::RustMyQueryNamesOnPerson {
32+
query_on_union::MyQueryNames::Person(query_on_union::MyQueryNamesOnPerson {
3333
first_name: "Audrey".to_string(),
3434
last_name: Some("Lorde".to_string()),
3535
}),
36-
query_on_union::RustMyQueryNames::Dog(query_on_union::RustMyQueryNamesOnDog {
36+
query_on_union::MyQueryNames::Dog(query_on_union::MyQueryNamesOnDog {
3737
name: "Laïka".to_string(),
3838
}),
39-
query_on_union::RustMyQueryNames::Organization(
40-
query_on_union::RustMyQueryNamesOnOrganization {
39+
query_on_union::MyQueryNames::Organization(
40+
query_on_union::MyQueryNamesOnOrganization {
4141
title: "Mozilla".to_string(),
4242
},
4343
),
44-
query_on_union::RustMyQueryNames::Dog(query_on_union::RustMyQueryNamesOnDog {
44+
query_on_union::MyQueryNames::Dog(query_on_union::MyQueryNamesOnDog {
4545
name: "Norbert".to_string(),
4646
}),
4747
]),
@@ -60,25 +60,25 @@ fn type_refining_fragment_on_interface() {
6060

6161
let expected = ResponseData {
6262
everything: Some(vec![
63-
RustMyQueryEverything {
63+
MyQueryEverything {
6464
name: "Audrey Lorde".to_string(),
65-
on: RustMyQueryEverythingOn::Person(RustMyQueryEverythingOnPerson {
65+
on: MyQueryEverythingOn::Person(MyQueryEverythingOnPerson {
6666
birthday: Some("1934-02-18".to_string()),
6767
}),
6868
},
69-
RustMyQueryEverything {
69+
MyQueryEverything {
7070
name: "Laïka".to_string(),
71-
on: RustMyQueryEverythingOn::Dog(RustMyQueryEverythingOnDog { is_good_dog: true }),
71+
on: MyQueryEverythingOn::Dog(MyQueryEverythingOnDog { is_good_dog: true }),
7272
},
73-
RustMyQueryEverything {
73+
MyQueryEverything {
7474
name: "Mozilla".to_string(),
75-
on: RustMyQueryEverythingOn::Organization(RustMyQueryEverythingOnOrganization {
75+
on: MyQueryEverythingOn::Organization(MyQueryEverythingOnOrganization {
7676
industry: Industry::OTHER,
7777
}),
7878
},
79-
RustMyQueryEverything {
79+
MyQueryEverything {
8080
name: "Norbert".to_string(),
81-
on: RustMyQueryEverythingOn::Dog(RustMyQueryEverythingOnDog { is_good_dog: true }),
81+
on: MyQueryEverythingOn::Dog(MyQueryEverythingOnDog { is_good_dog: true }),
8282
},
8383
]),
8484
};

graphql_client/tests/union_query.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,17 @@ fn union_query_deserialization() {
2121

2222
let expected = union_query::ResponseData {
2323
names: Some(vec![
24-
union_query::RustMyQueryNames::Person(union_query::RustMyQueryNamesOnPerson {
24+
union_query::MyQueryNames::Person(union_query::MyQueryNamesOnPerson {
2525
first_name: "Audrey".to_string(),
2626
last_name: Some("Lorde".to_string()),
2727
}),
28-
union_query::RustMyQueryNames::Dog(union_query::RustMyQueryNamesOnDog {
28+
union_query::MyQueryNames::Dog(union_query::MyQueryNamesOnDog {
2929
name: "Laïka".to_string(),
3030
}),
31-
union_query::RustMyQueryNames::Organization(
32-
union_query::RustMyQueryNamesOnOrganization {
33-
title: "Mozilla".to_string(),
34-
},
35-
),
36-
union_query::RustMyQueryNames::Dog(union_query::RustMyQueryNamesOnDog {
31+
union_query::MyQueryNames::Organization(union_query::MyQueryNamesOnOrganization {
32+
title: "Mozilla".to_string(),
33+
}),
34+
union_query::MyQueryNames::Dog(union_query::MyQueryNamesOnDog {
3735
name: "Norbert".to_string(),
3836
}),
3937
]),

graphql_client_codegen/src/codegen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pub fn response_for_query(
8080
.objects
8181
.get(&root_name)
8282
.expect("schema declaration is invalid");
83-
let prefix = format!("RUST_{}", operation.name);
83+
let prefix = &operation.name;
8484
let selection = &operation.selection;
8585

8686
if operation.is_subscription() && selection.0.len() > 1 {

0 commit comments

Comments
 (0)