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."); | |
}); |
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
query{ | |
Posts{ | |
id, | |
title, | |
description, | |
createDate, | |
author | |
} | |
} |
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
mutation { | |
createPost(title: "Mi primer Post", description: "en mi primer post tengo que la vida no es facil", createDate:"25-09-2019",author:"Jesus GIlbert") { | |
id, | |
title, | |
description, | |
createDate, | |
author | |
} | |
} |
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
mutation { | |
updatePost( | |
id:2, | |
title: "Mi segundo Post", | |
description: "en mi primer post tengo que la vida no es facil", | |
createDate:"26-09-2019", | |
author:"Jesus GIlbert" | |
) | |
} |
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
mutation { | |
deletePost(id:1) | |
} |
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
import Vue from "vue"; | |
import App from "./App.vue"; | |
import router from "./router"; | |
import store from "./store"; | |
//import apolloclient and vueapollo | |
import ApolloClient from "apollo-boost"; | |
import VueApollo from "vue-apollo"; | |
Vue.config.productionTip = false; | |
// define const apolloClient to set graphql api url |
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
<template> | |
<div> | |
<div v-for="post in Posts" :key="post.id"> | |
<div style="font-size: 20px; font-weight: 700;">{{ post.title }}</div> | |
<div style="text-align: justify; width:800px; margin:0 auto;"> | |
<p> | |
{{ post.description }} | |
</p> | |
</div> | |
<div style="text-align: right; width:800px; margin:0 auto;"> |
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
<template> | |
<div> | |
<div v-for="post in Posts" :key="post.id"> | |
<div style="font-size: 20px; font-weight: 700;">{{ post.title }}</div> | |
<div style="text-align: justify; width:800px; margin:0 auto;"> | |
<p> | |
{{ post.description }} | |
</p> | |
</div> | |
<div style="text-align: right; width:800px; margin:0 auto;"> |
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
<template> | |
<div> | |
<div style="text-align: left; width:800px; margin:0 auto;"> | |
<strong>Title</strong> | |
</div> | |
<div style="text-align: center; width:800px; margin:0 auto;"> | |
<input style="width:800px" type="text" id="title" name="title" value="" v-model="title" /> | |
</div> | |
<br /> | |
<div style="text-align: left; width:800px; margin:0 auto;"> |
OlderNewer