Browse Source

fix(server): Fix GraphQL schema violations in return values

Michael Bromley 7 years ago
parent
commit
16893238c8

+ 2 - 1
server/src/api/product-option/product-option.resolver.ts

@@ -44,7 +44,8 @@ export class ProductOptionResolver {
 
         if (input.options && input.options.length) {
             for (const option of input.options) {
-                await this.productOptionService.create(group, option);
+                const newOption = await this.productOptionService.create(group, option);
+                group.options.push(newOption);
             }
         }
         return group;

+ 1 - 1
server/src/service/product.service.ts

@@ -100,7 +100,7 @@ export class ProductService {
 
         return await this.connection
             .getRepository(ProductVariant)
-            .findByIds(updateProductVariants.map(v => v.id))
+            .findByIds(updateProductVariants.map(v => v.id), { relations: ['options'] })
             .then(variants => {
                 return variants.map(v => translateDeep(v, DEFAULT_LANGUAGE_CODE));
             });