Skip to content

Commit f34ee26

Browse files
committed
Generate structs implementing GraphQLQuery in the CLI workflow
1 parent df091a7 commit f34ee26

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

graphql_client_codegen/src/generated_module.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::codegen_options::*;
12
use heck::*;
23
use proc_macro2::{Ident, Span, TokenStream};
34

@@ -43,7 +44,15 @@ impl<'a> GeneratedModule<'a> {
4344
let query_string = &self.query_string;
4445
let impls = self.build_impls()?;
4546

47+
let struct_declaration = match self.options.mode {
48+
CodegenMode::Cli => quote!(#module_visibility struct #operation_name_ident),
49+
// The struct is already present in derive mode.
50+
CodegenMode::Derive => quote!(),
51+
};
52+
4653
Ok(quote!(
54+
#struct_declaration
55+
4756
#module_visibility mod #module_name {
4857
#![allow(non_camel_case_types)]
4958
#![allow(non_snake_case)]

graphql_client_codegen/src/operations.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ impl<'query> Operation<'query> {
3939
}
4040

4141
/// Generate the Variables struct and all the necessary supporting code.
42-
pub(crate) fn expand_variables(
43-
&self,
44-
context: &QueryContext,
45-
) -> TokenStream {
42+
pub(crate) fn expand_variables(&self, context: &QueryContext) -> TokenStream {
4643
let variables = &self.variables;
4744
let variables_derives = context.variables_derives();
4845

0 commit comments

Comments
 (0)