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
| { | |
| "data": { | |
| "coins": [ | |
| { | |
| "name": "Ethereum", | |
| "id": "620a7804ded99924b9dda1fc" | |
| }, | |
| { | |
| "name": "Flux", | |
| "id": "620a78c2ded99924b9dda200" |
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
| mutation createCoin{ | |
| createCoin(input: { | |
| name: "Ethereum" | |
| }){ | |
| id | |
| name | |
| } | |
| } |
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
| { | |
| "data": { | |
| "coins": [] | |
| } | |
| } |
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
| query FirstQuery { | |
| coins { | |
| name | |
| id | |
| } | |
| } |
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
| const server = new ApolloServer({ | |
| typeDefs, | |
| resolvers, | |
| context: {models} | |
| }); | |
| // port: process.env.PORT yet undefined but we will have this variable | |
| // once we deployed to heroku | |
| server.listen({port: process.env.PORT || 4000}).then(({url}) => { | |
| console.log(`Server is ready at ${url}`); |
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
| const {ApolloServer} = require('apollo-server'); | |
| const connectDB = require('./config/db'); | |
| const typeDefs = require('./types'); | |
| const resolvers = require('./resolvers'); | |
| const models = require('./models'); |
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
| \_ Server | |
| \_ node_modules | |
| \_ src | |
| \_ config | |
| \_ models | |
| \_ resolvers | |
| \_ types | |
| \_ index.js <= this one | |
| \_ .env | |
| \_ package.json |
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
| require('dotenv').config(); | |
| const mongoose = require('mongoose'); | |
| const DATABASE_URL = process.env.DATABASE_URL; | |
| const connectDB = () => { | |
| return mongoose.connect(DATABASE_URL, {useUnifiedTopology: true, useNewUrlParser: true}, err => { | |
| if (err){ | |
| console.error('Connection to DB failed'); |
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
| \_ Server | |
| \_ node_modules | |
| \_ src | |
| \_ config | |
| \_ db.js | |
| \_ .env | |
| \_ package.json | |
| \_ package-lock.json |
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
| \_Server | |
| \_ node_modules | |
| \_ src | |
| \_ .env | |
| \_ package.json | |
| \_ package-lock.json |