Skip to content

Commit

Permalink
Merge pull request #1 from vardhanapoorv/master
Browse files Browse the repository at this point in the history
update
  • Loading branch information
raregamer authored Oct 13, 2019
2 parents dcd2592 + 3d8c329 commit 8730705
Show file tree
Hide file tree
Showing 17 changed files with 808 additions and 125 deletions.
21 changes: 20 additions & 1 deletion next/contributors-site/static/contributors.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@
"name": "Temilayo Subair",
"twitter":"https://twitter.com/temi_subair",
"github":"https://github.com/fersubair40"
},
{

"name": "Benny Ogidan",
"twitter": "https://twitter.com/BennyOgidan",
"github": "https://github.com/benfluleck"
},
{
"name": "Cindy Le",
"twitter":"https://twitter.com/dotwiggle",
"github":"https://github.com/cindyledev"

},
{
"name": "Jose Garrido",
"github":"https://github.com/josej30"
},
{
"name": "Amelie Oller",
"github": "https://github.com/amelieoller"
}
]

42 changes: 32 additions & 10 deletions node/greek-mythology/appwithgraphqlusingapollo/app.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,44 @@
/*
* @Author: Apoorv Vardhan
* @Date: 2019-09-22 23:25:03
* @Last Modified by: Apoorv Vardhan
* @Last Modified time: 2019-09-22 23:46:04
*/
 * @Author: Apoorv Vardhan
 * @Date: 2019-09-22 23:25:03
 * @Last Modified by: Apoorv Vardhan
 * @Last Modified time: 2019-09-22 23:46:04
 */

/*
TODO: Create the GraphQL setup using Apollo-Server. Refer Apollo Docs for help.
TODO: Create the GraphQL setup using Apollo-Server. Refer Apollo Docs for help.
*/

const mongoose = require('mongoose');
const express = require('express');
const { ApolloServer } = require('apollo-server-express');

const typeDefs = require('./graphql/typeDefs');
const resolvers = require('./graphql/resolvers/greekgod');
const models = require('./models')

const app = express();
const port = 4000 || process.env.PORT;


mongoose.set('useUnifiedTopology', true);

mongoose.connect(
`mongodb+srv://${process.env.MONGO_USER}:${process.env.MONGO_PASSWORD}@oss-contri-jmuc0.mongodb.net/${process.env.MONGO_DB}?retryWrites=true&w=majority`
, {useNewUrlParser: true}).then(() => {
app.listen(8000);
}).catch(err => {
console.log(err);
, { useNewUrlParser: true })


const server = new ApolloServer({
typeDefs,
resolvers,
context: { models }
})

server.applyMiddleware({ app })


app.listen({ port }, () => {
console.log(`Server started http://localhost:${port}${server.graphqlPath}`)
}).on('error', () => {
console.log(error)
})
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const GreekGod = require('../../models/greekgod');

module.exports = {
greekGods: async () => {
try {
const greekGods = await GreekGod.find()
return greekGods;
} catch (err) {
throw err;
}
Query: {
greekGods: async (root,_,{ models }) => {
try {
const greekGods = await models.GreekGod.find()
return greekGods;
} catch (err) {
throw err;
}
}
};
},
};

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const { gql } = require('apollo-server-express')

module.exports = gql`
type GreekGod {
_id: ID!
name: String!
desc: String!
}
input GodInput {
name: String!
desc: String!
}
type Query {
greekGods: [GreekGod!]!
}
type Mutation {
addGod(godInput: GodInput): GreekGod
}`
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const GreekGod = require('./greekgod');

module.exports = {
GreekGod
}
Loading

0 comments on commit 8730705

Please sign in to comment.