@@ -202,13 +202,17 @@ exports.sourceNodes = async (
202202 }
203203 }
204204
205- const { data : brands } = await moltin . get ( 'brands' )
206- const { data : categories } = await getPaginatedResource ( 'categories' )
207- const { data : collections } = await getPaginatedResource ( 'collections' )
208- const {
209- data : products ,
210- included : { main_images = { } , files = [ ] } = { }
211- } = await getPaginatedResource ( 'products' , { } , `?include=main_image,files` )
205+ const [
206+ { data : brands } ,
207+ { data : categories } ,
208+ { data : collections } ,
209+ { data : products , included : { main_images = { } , files = [ ] } = { } }
210+ ] = await Promise . all ( [
211+ moltin . get ( 'brands' ) ,
212+ getPaginatedResource ( 'categories' ) ,
213+ getPaginatedResource ( 'collections' ) ,
214+ getPaginatedResource ( 'products' , { } , `?include=main_image,files` )
215+ ] )
212216
213217 const createCategories = async ( { categories } ) => {
214218 categories . forEach ( async category =>
@@ -226,39 +230,30 @@ exports.sourceNodes = async (
226230 brands . forEach ( async brand => createNode ( await processBrand ( { brand } ) ) )
227231 }
228232
229- const createProducts = async ( {
230- products,
231- main_images,
232- categories,
233- collections,
234- brands,
235- files
236- } ) => {
233+ const createProducts = async ( { products, ...rest } ) => {
237234 products . forEach ( async product =>
238235 createNode (
239236 await processProduct ( {
240237 product,
241- main_images,
242- categories,
243- collections,
244- brands,
245- files
238+ ...rest
246239 } )
247240 )
248241 )
249242 }
250243
251- await createProducts ( {
252- products,
253- main_images,
254- categories,
255- collections,
256- brands,
257- files
258- } )
259- await createCollections ( { collections } )
260- await createCategories ( { categories } )
261- await createBrands ( { brands } )
244+ await Promise . all ( [
245+ createProducts ( {
246+ products,
247+ main_images,
248+ categories,
249+ collections,
250+ brands,
251+ files
252+ } ) ,
253+ createCollections ( { collections } ) ,
254+ createCategories ( { categories } ) ,
255+ createBrands ( { brands } )
256+ ] )
262257}
263258
264259exports . onCreateNode = async ( {
0 commit comments