-
Notifications
You must be signed in to change notification settings - Fork 371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
code doesn't run out of the box anymore #24
Comments
You can use a local instance of Mongodb as well. In that case, the URI would just be something like: "mongodb://127.0.0.1/lyricaldb" |
thanks for the info. |
code needs to be updated. mongodb url is not valid according to the code. Latest version of mongoose works though |
This works for me! Install latest mongoose (5.7.13) and instead of MLab, use MongoDB Atlas, and change server.js file into something like this: const express = require("express");
const models = require("./models");
const expressGraphQL = require("express-graphql");
const mongoose = require("mongoose");
const bodyParser = require("body-parser");
const schema = require("./schema/schema");
const app = express();
const MONGO_URI =
"mongodb+srv://nenad:<PASSWORDHERE>@cluster0-lxh0n.mongodb.net/lyricaldb";
if (!MONGO_URI) {
throw new Error("You must provide a MongoDB URI");
}
mongoose.Promise = global.Promise;
mongoose.connect(MONGO_URI, {
useUnifiedTopology: true,
useNewUrlParser: true
});
mongoose.connection
.once("open", () => console.log("Connected to MongoDB."))
.on("error", error => console.log("Error connecting to MongoLab:", error));
app.use(bodyParser.json());
app.use(
"/graphql",
expressGraphQL({
schema,
graphiql: true
})
);
const webpackMiddleware = require("webpack-dev-middleware");
const webpack = require("webpack");
const webpackConfig = require("../webpack.config.js");
app.use(webpackMiddleware(webpack(webpackConfig)));
module.exports = app; |
I don't know if it just needs module updating or what, but mLab doesn't even exist anymore.
I bought the tutorial on udemy yesterday thinking it was new.
The text was updated successfully, but these errors were encountered: