An example repo using apollo, react, mongod, and express-graphql
Server and Client side have separate package.json
and yarn.lock
files
From the root project folder, run yarn
The credentials for mlab.com must be exported as shell environment variables.
$ export MLAB_USERNAME=''
$ export MLAB_PASSWORD=''
This must be done every time a new terminal window is opened and used for the server side.
- Open up a tab in the terminal and start MongoDB
- Open up a tab in the terminal. From the root project folder, run:
yarn start
Requires the Node.js V8 inspector extension
To debug the server enter a debugging
line in the server codebase.
Example: ./server/schema/schema.js
resolve(parent, args) {
debugger;
return Book.findById(args.id);
},
Then run yarn run debug
to run the server in debug mode. Open Chrome and the
inspector (dev tools). Click the green Node.js V8 inspector extension icon. Use
breakpoints as necessary to move through the code and inspect.
From the Client
folder, run: yarn
Open up a tab in the terminal. From the Client
project folder, run: yarn start
The GraphQL schema docs are located in: server/models
- Open up a tab in the terminal and start MongoDB
- Open up a tab in the terminal. From the root project folder, run:
yarn start
An in-browser IDE for writing, validating, and testing queries
The Client side schema file is located at: client/src/components/BookList.js
.nvmrc added to both Server and Client side for node version consistency
The Client side was originally created without create-react-app (though was available at this time) and Relay. Relay was replaced with Apollo for its flexibility within the environment. A connection with MongoDB depicts this. After working with Apollo's more lightweight and flexible approach, a future application(requiring more complex data) will be developed using Relay.