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 bodyParser = require('body-parser') | |
const mongoose = require('mongoose') | |
const cors = require('cors') | |
const {graphiqlExpress, graphqlExpress} = require('apollo-server-express') | |
const morgan = require('morgan') | |
// require app modules | |
const config = require('./config/config') | |
const schema = require('./graphql') |
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
module.exports = { | |
PORT: process.env.PORT || 6060, | |
DBURI: process.env.DBURI || 'mongodb://localhost:27017/auth', | |
SECRET: process.env.SECRET || 'bhsvchldjvbscivgjsbnvspiucbvl' | |
} |
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
module.exports = ` | |
type Query { | |
hello: String! | |
} | |
` |
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
module.exports = { | |
Query: { | |
hello (root, args, context) { | |
return 'Hello world!!' | |
} | |
} | |
} |
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 {makeExecutableSchema} = require('graphql-tools') | |
const resolvers = require('./resolvers') | |
const typeDefs = require('./typeDefs') | |
module.exports = makeExecutableSchema({ | |
typeDefs, | |
resolvers | |
}) |
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 mongoose = require('mongoose') | |
const bcryptjs = require('bcryptjs') | |
const jwt = require('jsonwebtoken') | |
const config = require('../config/config') | |
// user schema | |
const userSchema = new mongoose.Schema({ | |
username: { | |
type: String, | |
required: true | |
}, |
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 User = require('./user') | |
module.exports = { | |
User | |
} |
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
module.exports = ` | |
type User { | |
id: ID! | |
email: String! | |
username: String! | |
password: String! | |
createAt: String! | |
} | |
type Query { | |
hello : String! |
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
module.exports = { | |
Query: { | |
hello (root, args, context) { | |
return 'Hello World!!' | |
} | |
}, | |
Mutation: { | |
async createUser (root, args, {DB}) { | |
const {username, email, password} = args | |
const user = await DB.User.createUser(email, username, password) |
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 bodyParser = require('body-parser') | |
const mongoose = require('mongoose') | |
const cors = require('cors') | |
const {graphiqlExpress, graphqlExpress} = require('apollo-server-express') | |
const morgan = require('morgan') | |
// require app modules | |
const config = require('./config/config') | |
const schema = require('./graphql') |
OlderNewer