From 60d4d312f1bce6848bf5a62442136e318c881842 Mon Sep 17 00:00:00 2001 From: Niklas Fondberg Date: Tue, 19 Apr 2022 13:02:48 +0200 Subject: [PATCH] Add prod from CMS (#111) --- Dockerfile-dev | 1 + src/datasources/product-api.ts | 8 +++++++- src/resolvers/products-resolver.ts | 3 ++- src/schema.graphql | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Dockerfile-dev b/Dockerfile-dev index c378614..0310fc6 100644 --- a/Dockerfile-dev +++ b/Dockerfile-dev @@ -7,5 +7,6 @@ EXPOSE 4000 WORKDIR /app # Set node env ENV NODE_ENV=development +ENV NEW_RELIC_NO_CONFIG_FILE=true # Command container will actually run when called CMD ["npx", "nodemon", "-w", "src", "--ext", "ts", "--exec", "ts-node", "src/index.ts"] diff --git a/src/datasources/product-api.ts b/src/datasources/product-api.ts index 1f54da3..bc6ded4 100644 --- a/src/datasources/product-api.ts +++ b/src/datasources/product-api.ts @@ -305,6 +305,7 @@ export class ProductAPI extends BaseSQLDataSource { return ids.map(async (id) => this.getProduct(id)); } + // // mutations below async updateProductField( productId: number, @@ -383,7 +384,11 @@ export class ProductAPI extends BaseSQLDataSource { * @description Adds a new product to system, will use batchname and name to * set a unique path, artNo is the productId with e infront. */ - async addProduct(name: string, batch: string): Promise { + async addProduct( + name: string, + batch: string, + designerId: number, + ): Promise { const fixedBatch = !!batch ? batch : ''; const path = batch ? fixedBatch + ' ' + name : name; const productPath = slug(path); @@ -395,6 +400,7 @@ export class ProductAPI extends BaseSQLDataSource { path: slug(safePath), browsable: 0, visible: 0, + designerid: designerId, }) .returning('productid'); const id = idres[0].productid; diff --git a/src/resolvers/products-resolver.ts b/src/resolvers/products-resolver.ts index 2ca6f69..2732304 100644 --- a/src/resolvers/products-resolver.ts +++ b/src/resolvers/products-resolver.ts @@ -140,11 +140,12 @@ export const productMutationTypeDefs = { * @function addProduct * @description Will add a product */ - async addProduct(_, { name, batch }, { dataSources, auth }) { + async addProduct(_, { name, batch, designerId }, { dataSources, auth }) { checkAccess(['products.write'], auth); const id = await (dataSources.productApi).addProduct( name, batch, + designerId, ); return (dataSources.productApi).getProduct(id); }, diff --git a/src/schema.graphql b/src/schema.graphql index ede56c9..70373d3 100644 --- a/src/schema.graphql +++ b/src/schema.graphql @@ -440,7 +440,7 @@ type Mutation { """ Product """ - addProduct(name: String!, batch: String): Product + addProduct(name: String!, batch: String, designerId: Int): Product productInfo(productId: Int!, info: ProductInfoInput!): Product productWallpaperType( productId: Int!