@@ -60,7 +60,7 @@ fn get_publish_response_from_data(
60
60
}
61
61
62
62
fn build_response ( publish_response : UpdateResponse ) -> SubgraphPublishResponse {
63
- let composition_errors: Vec < CompositionError > = publish_response
63
+ let composition_errors: CompositionErrors = publish_response
64
64
. errors
65
65
. iter ( )
66
66
. filter_map ( |error| {
@@ -71,23 +71,14 @@ fn build_response(publish_response: UpdateResponse) -> SubgraphPublishResponse {
71
71
} )
72
72
. collect ( ) ;
73
73
74
- // if there are no errors, just return None
75
- let composition_errors = if !composition_errors. is_empty ( ) {
76
- Some ( CompositionErrors { composition_errors } )
77
- } else {
78
- None
79
- } ;
80
-
81
74
SubgraphPublishResponse {
82
75
schema_hash : match publish_response. composition_config {
83
76
Some ( config) => Some ( config. schema_hash ) ,
84
77
None => None ,
85
78
} ,
86
79
supergraph_was_updated : publish_response. did_update_gateway ,
87
80
subgraph_was_created : publish_response. service_was_created ,
88
- composition_errors : composition_errors. unwrap_or_else ( || CompositionErrors {
89
- composition_errors : vec ! [ ] ,
90
- } ) ,
81
+ composition_errors,
91
82
}
92
83
}
93
84
@@ -120,18 +111,17 @@ mod tests {
120
111
output,
121
112
SubgraphPublishResponse {
122
113
schema_hash: Some ( "5gf564" . to_string( ) ) ,
123
- composition_errors: CompositionErrors {
124
- composition_errors: vec![
125
- CompositionError {
126
- message: "[Accounts] User -> composition error" . to_string( ) ,
127
- code: None
128
- } ,
129
- CompositionError {
130
- message: "[Products] Product -> another one" . to_string( ) ,
131
- code: Some ( "ERROR" . to_string( ) )
132
- }
133
- ]
134
- } ,
114
+ composition_errors: vec![
115
+ CompositionError {
116
+ message: "[Accounts] User -> composition error" . to_string( ) ,
117
+ code: None
118
+ } ,
119
+ CompositionError {
120
+ message: "[Products] Product -> another one" . to_string( ) ,
121
+ code: Some ( "ERROR" . to_string( ) )
122
+ }
123
+ ]
124
+ . into( ) ,
135
125
supergraph_was_updated: false ,
136
126
subgraph_was_created: true ,
137
127
}
@@ -153,9 +143,7 @@ mod tests {
153
143
output,
154
144
SubgraphPublishResponse {
155
145
schema_hash: Some ( "5gf564" . to_string( ) ) ,
156
- composition_errors: CompositionErrors {
157
- composition_errors: vec![ ]
158
- } ,
146
+ composition_errors: CompositionErrors :: new( ) ,
159
147
supergraph_was_updated: true ,
160
148
subgraph_was_created: true ,
161
149
}
@@ -182,12 +170,11 @@ mod tests {
182
170
output,
183
171
SubgraphPublishResponse {
184
172
schema_hash: None ,
185
- composition_errors: CompositionErrors {
186
- composition_errors: vec![ CompositionError {
187
- message: "[Accounts] -> Things went really wrong" . to_string( ) ,
188
- code: None
189
- } ]
190
- } ,
173
+ composition_errors: vec![ CompositionError {
174
+ message: "[Accounts] -> Things went really wrong" . to_string( ) ,
175
+ code: None
176
+ } ]
177
+ . into( ) ,
191
178
supergraph_was_updated: false ,
192
179
subgraph_was_created: false ,
193
180
}
0 commit comments