File tree Expand file tree Collapse file tree 2 files changed +11
-12
lines changed
graphql_client_codegen/src Expand file tree Collapse file tree 2 files changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -69,20 +69,19 @@ pub(crate) fn response_for_query(
6969 }
7070
7171 let response_data_fields = {
72- let opt_root_name = operation. root_name ( & context. schema ) ;
73- let root_name: & str = if let Some ( root_name) = opt_root_name {
74- root_name
72+ let root_name = operation. root_name ( & context. schema ) ;
73+ let opt_definition = context
74+ . schema
75+ . objects
76+ . get ( & root_name) ;
77+ let definition = if let Some ( definition) = opt_definition {
78+ definition
7579 } else {
7680 panic ! (
7781 "operation type '{:?}' not in schema" ,
7882 operation. operation_type
7983 ) ;
8084 } ;
81- let definition = context
82- . schema
83- . objects
84- . get ( & root_name)
85- . expect ( "schema declaration is invalid" ) ;
8685 let prefix = & operation. name ;
8786 let selection = & operation. selection ;
8887
Original file line number Diff line number Diff line change @@ -26,11 +26,11 @@ impl<'query> Operation<'query> {
2626 pub ( crate ) fn root_name < ' schema > (
2727 & self ,
2828 schema : & ' schema :: schema:: Schema ,
29- ) -> Option < & ' schema str > {
29+ ) -> & ' schema str {
3030 match self . operation_type {
31- OperationType :: Query => schema. query_type ,
32- OperationType :: Mutation => schema. mutation_type ,
33- OperationType :: Subscription => schema. subscription_type ,
31+ OperationType :: Query => schema. query_type . unwrap_or ( "Query" ) ,
32+ OperationType :: Mutation => schema. mutation_type . unwrap_or ( "Mutation" ) ,
33+ OperationType :: Subscription => schema. subscription_type . unwrap_or ( "Subscription" ) ,
3434 }
3535 }
3636
You can’t perform that action at this time.
0 commit comments