<file_sep>const mongoose = require('mongoose');
const schema = mongoose.Schema;

// We don't have to include the "id:" field because MongoDB
// will create its own
const authorSchema = new schema({
	name: String,
	age: Number
});

// making a model (collection) of authors that contains objects
// that look like the "authorSchema" schema
module.exports = mongoose.model('Author', authorSchema);<file_sep>const express = require('express');
const graphqlHTTP = require('express-graphql');
const schema = require('./schema/schema');
const mongoose = require('mongoose');

const app = express();

// connect to mLab database
mongoose.connect('mongodb://jenn:<EMAIL>:51022/gql-ninja');
// once a connection is made, fire off a function
mongoose.connection.once('open', () => {
	console.log('Connected to database')
});

// set up middleware. when a GraphQL request is made it is
// handed off to the express-graphql function
app.use('/graphql',graphqlHTTP({
	// below ES6 version of saying schema: schema
	schema,
	graphiql: true
}));

app.listen(4000, () => {
	console.log('now listening for requests on port 4000');
});