Skip to content

Commit

Permalink
Merge branch 'main' into productInventory
Browse files Browse the repository at this point in the history
  • Loading branch information
KiranJoji authored Apr 8, 2024
2 parents e2af28b + c59de61 commit 9c059c2
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 4 deletions.
15 changes: 15 additions & 0 deletions prisma/migrations/20240314173520_init/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- CreateTable
CREATE TABLE "Products" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"price" INTEGER NOT NULL,
"description" TEXT NOT NULL,
"details" TEXT NOT NULL,
"weight" INTEGER NOT NULL,
"height" INTEGER NOT NULL,
"width" INTEGER NOT NULL,
"depth" INTEGER NOT NULL,
"special_label_needed" BOOLEAN NOT NULL,

CONSTRAINT "Products_pkey" PRIMARY KEY ("id")
);
2 changes: 1 addition & 1 deletion prisma/models/Product.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ model Products {
width Int
depth Int
special_label_needed Boolean
}
}
6 changes: 3 additions & 3 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ model Product {
id String @id @default(uuid())
inventory Inventory? @relation("product_inventory")
name String
price Int
price Float
description String
details String
weight Int
Expand All @@ -25,10 +25,10 @@ model Inventory {
id String @id @unique
product Product @relation("product_inventory", fields: [id], references: [id], onDelete: Cascade)
available_quantity Int
cost_of_production Int
cost_of_production Float
lead_time Int
reorder_point Int
reorder_quantity Int
safety_stock Int
stock_on_order Int
}
}
15 changes: 15 additions & 0 deletions src/resolvers/Products.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Products from "../services/Products";

const resolvers = {
Query: {
products: (_, { id }) => Products.find({ id }),
manyProducts: (_, { ids }) => Products.findAll({ ids }),
},
Mutation: {
createProducts: (_, { input }) => Products.create({ input }),
updateProducts: (_, { id, input }) => Products.update({ id, input }),
deleteProducts: (_, { id }) => Products.delete({ id }),
},
};

export default resolvers;
52 changes: 52 additions & 0 deletions src/typeDefs/Products.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import gql from "graphql-tag";

const typeDefs = gql`
type Products {
id: ID!
name: String!
price: Int!
description: String!
details: String!
weight: Int!
height: Int!
width: Int!
depth: Int!
special_label_needed: Boolean!
}
input ProductsInput {
name: String!
price: Int!
description: String!
details: String!
weight: Int!
height: Int!
width: Int!
depth: Int!
special_label_needed: Boolean!
}
input ProductsInputOptional {
name: String
price: Int
description: String
details: String
weight: Int
height: Int
width: Int
depth: Int
special_label_needed: Boolean
}
type Query {
products(id: ID!): Products
manyProducts(id: [ID]): [Products]
}
type Mutation {
createProducts(input: ProductsInput!): Products
updateProducts(id: ID!, input: ProductsInputOptional!): Products
deleteProducts(id: ID!): Boolean
}
`;
export default typeDefs;

0 comments on commit 9c059c2

Please sign in to comment.