Skip to content

Commit e29f381

Browse files
authored
Merge pull request #39 from tomhoule/wasm
Fix generated module imports
2 parents 3ec85fb + 42d6314 commit e29f381

File tree

4 files changed

+36
-25
lines changed

4 files changed

+36
-25
lines changed

graphql_query_derive/src/introspection_response.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -223,74 +223,74 @@ pub struct TypeRef {
223223
#[derive(Clone, Debug, Deserialize)]
224224
#[serde(rename_all = "camelCase")]
225225
pub struct TypeRefOfTypeOfTypeOfTypeOfTypeOfTypeOfTypeOfType {
226-
kind: Option<__TypeKind>,
227-
name: Option<String>,
226+
pub kind: Option<__TypeKind>,
227+
pub name: Option<String>,
228228
}
229229

230230
#[derive(Clone, Debug, Deserialize)]
231231
#[serde(rename_all = "camelCase")]
232232
pub struct TypeRefOfTypeOfTypeOfTypeOfTypeOfTypeOfType {
233-
kind: Option<__TypeKind>,
234-
name: Option<String>,
235-
of_type: Option<TypeRefOfTypeOfTypeOfTypeOfTypeOfTypeOfTypeOfType>,
233+
pub kind: Option<__TypeKind>,
234+
pub name: Option<String>,
235+
pub of_type: Option<TypeRefOfTypeOfTypeOfTypeOfTypeOfTypeOfTypeOfType>,
236236
}
237237

238238
#[derive(Clone, Debug, Deserialize)]
239239
#[serde(rename_all = "camelCase")]
240240
pub struct TypeRefOfTypeOfTypeOfTypeOfTypeOfType {
241-
kind: Option<__TypeKind>,
242-
name: Option<String>,
243-
of_type: Option<TypeRefOfTypeOfTypeOfTypeOfTypeOfTypeOfType>,
241+
pub kind: Option<__TypeKind>,
242+
pub name: Option<String>,
243+
pub of_type: Option<TypeRefOfTypeOfTypeOfTypeOfTypeOfTypeOfType>,
244244
}
245245

246246
#[derive(Clone, Debug, Deserialize)]
247247
#[serde(rename_all = "camelCase")]
248248
pub struct TypeRefOfTypeOfTypeOfTypeOfType {
249-
kind: Option<__TypeKind>,
250-
name: Option<String>,
251-
of_type: Option<TypeRefOfTypeOfTypeOfTypeOfTypeOfType>,
249+
pub kind: Option<__TypeKind>,
250+
pub name: Option<String>,
251+
pub of_type: Option<TypeRefOfTypeOfTypeOfTypeOfTypeOfType>,
252252
}
253253

254254
#[derive(Clone, Debug, Deserialize)]
255255
#[serde(rename_all = "camelCase")]
256256
pub struct TypeRefOfTypeOfTypeOfType {
257-
kind: Option<__TypeKind>,
258-
name: Option<String>,
259-
of_type: Option<TypeRefOfTypeOfTypeOfTypeOfType>,
257+
pub kind: Option<__TypeKind>,
258+
pub name: Option<String>,
259+
pub of_type: Option<TypeRefOfTypeOfTypeOfTypeOfType>,
260260
}
261261

262262
#[derive(Clone, Debug, Deserialize)]
263263
#[serde(rename_all = "camelCase")]
264264
pub struct TypeRefOfTypeOfType {
265-
kind: Option<__TypeKind>,
266-
name: Option<String>,
267-
of_type: Option<TypeRefOfTypeOfTypeOfType>,
265+
pub kind: Option<__TypeKind>,
266+
pub name: Option<String>,
267+
pub of_type: Option<TypeRefOfTypeOfTypeOfType>,
268268
}
269269

270270
#[derive(Clone, Debug, Deserialize)]
271271
#[serde(rename_all = "camelCase")]
272272
pub struct TypeRefOfType {
273-
kind: Option<__TypeKind>,
274-
name: Option<String>,
275-
of_type: Option<TypeRefOfTypeOfType>,
273+
pub kind: Option<__TypeKind>,
274+
pub name: Option<String>,
275+
pub of_type: Option<TypeRefOfTypeOfType>,
276276
}
277277

278278
#[derive(Clone, Debug, Deserialize)]
279279
#[serde(rename_all = "camelCase")]
280280
pub struct RustIntrospectionQuerySchemaQueryType {
281-
name: Option<String>,
281+
pub name: Option<String>,
282282
}
283283

284284
#[derive(Clone, Debug, Deserialize)]
285285
#[serde(rename_all = "camelCase")]
286286
pub struct RustIntrospectionQuerySchemaMutationType {
287-
name: Option<String>,
287+
pub name: Option<String>,
288288
}
289289

290290
#[derive(Clone, Debug, Deserialize)]
291291
#[serde(rename_all = "camelCase")]
292292
pub struct RustIntrospectionQuerySchemaSubscriptionType {
293-
name: Option<String>,
293+
pub name: Option<String>,
294294
}
295295

296296
#[derive(Clone, Debug, Deserialize)]

graphql_query_derive/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,13 @@ fn impl_gql_query(input: &syn::DeriveInput) -> Result<TokenStream, failure::Erro
103103
let schema_output = schema.response_for_query(query)?;
104104

105105
let result = quote!(
106-
mod #module_name {
106+
pub mod #module_name {
107107
#![allow(non_camel_case_types)]
108108
#![allow(non_snake_case)]
109109
#![allow(dead_code)]
110110

111+
use serde;
112+
111113
pub const QUERY: &'static str = #query_string;
112114

113115
#schema_output

graphql_query_derive/src/schema.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,11 @@ impl ::std::convert::From<::introspection_response::IntrospectionResponse> for S
280280
use introspection_response::__TypeKind;
281281

282282
let mut schema = Schema::new();
283-
let root = src.schema.expect("__Schema is not null");
283+
let root = src.schema.expect("__schema is not null");
284+
285+
schema.query_type = root.query_type.and_then(|ty| ty.name);
286+
schema.mutation_type = root.mutation_type.and_then(|ty| ty.name);
287+
schema.subscription_type = root.subscription_type.and_then(|ty| ty.name);
284288

285289
// Holds which objects implement which interfaces so we can populate GqlInterface#implemented_by later.
286290
// It maps interface names to a vec of implementation names.

graphql_query_derive/src/tests/github_schema.graphql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
schema {
2+
query: Query
3+
mutation: Mutation
4+
}
5+
16
# Autogenerated input type of AcceptTopicSuggestion
27
input AcceptTopicSuggestionInput {
38
# A unique identifier for the client performing the mutation.

0 commit comments

Comments
 (0)