File tree Expand file tree Collapse file tree 1 file changed +30
-3
lines changed
graphql_client_codegen/src Expand file tree Collapse file tree 1 file changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -120,9 +120,36 @@ impl<'a> WithQuery<'a, NodeId> {
120
120
fn upgrade ( & self ) -> WithQuery < ' a , SelectionItem < ' a > > {
121
121
let node = self . get_node ( ) ;
122
122
123
- match node {
124
- _ => panic ! ( ) ,
125
- }
123
+ let variant = match node. item {
124
+ QueryNode :: FragmentSpread ( frag_id) => {
125
+ SelectionVariant :: FragmentSpread ( self . query . fragments . get ( frag_id. 0 ) . unwrap ( ) )
126
+ }
127
+ QueryNode :: InlineFragment ( type_id) => {
128
+ SelectionVariant :: InlineFragment ( type_id. upgrade ( self . schema ) )
129
+ }
130
+ QueryNode :: Typename => SelectionVariant :: Typename ,
131
+ QueryNode :: SelectedField ( f) => SelectionVariant :: SelectedField {
132
+ alias : f. alias . as_ref ( ) . map ( String :: as_str) ,
133
+ field : self . schema . field ( f. field_id ) ,
134
+ } ,
135
+ } ;
136
+
137
+ self . refocus ( SelectionItem {
138
+ node_id : self . item ,
139
+ parent_id : self . parent_id ( ) ,
140
+ variant,
141
+ } )
142
+ }
143
+
144
+ fn parent_id ( & self ) -> Option < NodeId > {
145
+ self . query
146
+ . selection_graph
147
+ . edges_directed ( self . item , petgraph:: Direction :: Incoming )
148
+ . filter ( |edge| match edge. weight ( ) {
149
+ QueryEdge :: Selection => true ,
150
+ } )
151
+ . map ( |edge| edge. source ( ) )
152
+ . next ( )
126
153
}
127
154
}
128
155
You can’t perform that action at this time.
0 commit comments