Assumptions
- Mongodb running at mongodb://localhost:27017/graphqldb
- npm install && npm start
- Go to http://localhost:3000/graphiql to run GraphQL queries
- Uses mongoose as ORM for mongodb
- GraphQL schema at /src/database/typeDefs.graphql
- Mongoose schema at /src/database/mongooseSchema.js
- Reosolvers (at /src/resolvers.js) includes GraphQL Queries and Mutations
makeExecutableSchema
from Apollograph-tools
combines GraphQL schema and resolvers to create executable schema
[Note: There have been attempts to auto-generate GraphQL type from Mongoose Schema. https://www.npmjs.com/search?q=mongoose%20to%20graphql&page=1&ranking=optimal. It solves the problem of needing to write similar schema at 2 places.]