whisky/index.js
James Ketrenos 33131716ce Initial revision
Signed-off-by: James Ketrenos <james_eikona@ketrenos.com>
2021-04-26 17:55:27 -07:00

95 lines
1.4 KiB
JavaScript

const express = require('express');
const { graphqlHTTP } = require("express-graphql");
const schema = require("./graphql/whisky.js");
const app = express();
const cors = require("cors");
app.use(cors());
app.use("/graphql", graphqlHTTP({ schema: schema.schema, graphiql: true}));
/*
mutation {
createWhisky(
description: "Eagle Rare",
code:"4017B",
size: 750,
price: 59.95,
lastSeen: "2021-04-17") {
description,
code,
size,
price,
lastSeen
}
}
mutation {
createLocation(
address: "11820 SW Lanewood",
city: "Portland",
phone: "503 501 8281",
longitude: -110.0343,
latitude: 45) {
address,
city,
phone,
longitude,
latitude
}
}
mutation {
createInventory(
location: 1,
whisky: 1,
quantity: 5,
updated: "2021-04-21") {
location,
whisky,
quantity,
updated
}
}
query {
Whisky (id:1) {
description
price
code
size
inventories {
location {
address
phone
}
quantity
updated
}
}
Inventories {
location {
address
}
quantity
updated
}
Locations {
address
inventories {
whisky {
description
price
code
}
updated
quantity
}
}
}
*/
app.listen(4000, () => {
console.log("GraphQL server running at http://localhost:4000.");
});