This file contains hidden or 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 {model, Schema} from 'mongoose' | |
| const user = new Schema( | |
| { | |
| firstname: {type: String}, | |
| lastname: {type: String}, | |
| age: {type: Number}, | |
| email: {type: String}, | |
| password: {type: String} | |
| }, |
This file contains hidden or 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 {ApolloServerPluginDrainHttpServer} from 'apollo-server-core' | |
| import {ApolloServer} from 'apollo-server-express' | |
| import config from 'config' | |
| import express from 'express' | |
| import {GraphQLError} from 'graphql' | |
| import http from 'http' | |
| import {connectMongoDB} from './db/mongodb' | |
| import {mainSchema} from './src/schema-loader' // will create in next steps, skip for now | |
| const port = config.get('port') || 5000 |
This file contains hidden or 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 config from 'config' | |
| import {connect} from 'mongoose' // import connect method from mongoose | |
| const MONGO_URI: string = config.get('db_url') // This will get the db_url, that we've declared in config/default.json file | |
| export const connectMongoDB = async () => { | |
| try { | |
| const res = await connect(MONGO_URI) | |
| if (res) console.log('Connected to MongoDB') | |
| } catch (error) { |
This file contains hidden or 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
| { | |
| "port": 8000, | |
| "db_url": "mongodb+srv://<username>:<password>@sandbox.ejy8i.mongodb.net/graphqlDatabase?retryWrites=true&w=majority" | |
| } |
This file contains hidden or 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
| { | |
| "name": "node-graphql-curd", | |
| "version": "1.0.0", | |
| "description": "", | |
| "main": "index.js", | |
| "scripts": { | |
| "test": "echo \"Error: no test specified\" && exit 1", | |
| "start": "pm2 start server.js --watch" | |
| }, | |
| "keywords": [], |
This file contains hidden or 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
| --config | |
| --db | |
| --src | |
| --models | |
| --resolvers | |
| --schemas | |
| server.ts |
NewerOlder