This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const graphql = require("graphql"); | |
const sqlite3 = require('sqlite3').verbose(); | |
//create a database if no exists | |
const database = new sqlite3.Database("../micro-blog.db"); | |
//create a table to insert post | |
const createPostTable = () => { | |
const query = ` | |
CREATE TABLE IF NOT EXISTS posts ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const ExpressGraphQL = require("express-graphql"); | |
const schema = require("./graphql/post/post.js"); | |
const app = express(); | |
app.use("/graphql", ExpressGraphQL({ schema: schema.schema, graphiql: true})); | |
app.listen(4000, () => { | |
console.log("GraphQL server running at http://localhost:4000."); | |
}); |
NewerOlder