Skip to content

Instantly share code, notes, and snippets.

View jgilbertcastro's full-sized avatar
🎯
Focusing

Jesus Gilbert jgilbertcastro

🎯
Focusing
View GitHub Profile
@jgilbertcastro
jgilbertcastro / post.js
Last active August 21, 2020 12:27
post.js
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 (
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.");
});