A boilerplate project to get you started with GraphQL.
First, install the necessary dependencies:
npm install
Create the following two files:
- local.env
- dev.env
Populate the contents structured as you see in example-dev.env within local.env and dev.env with real information:
MONGO_DB_PASS=fakePassword MONGO_DB_USERNAME=fakePerson MONGO_DB_DATABASE=fakeDatabase MONGO_DB_HOSTNAME=fakedatabase.abcdefg.mongodb.net MONGO_DB_OPTIONS=retryWrites=true&w=majority&appName=fakedatabase
Create an account and create a database here to build your own credentials: https://account.mongodb.com/account/login
Find your uri: https://www.mongodb.com/docs/guides/atlas/connection-string/
Create your password by clicking the Database Access sidebar then click edit:
Run the application with the following
npm run local
or
npm run dev
You can test the GraphQL API using Postman or any other API client. After starting the server, you should be able to access the GraphQL Playground at the specified URL.
Or create an account with Postman https://www.postman.com/ and visualize the data like below:
- Modularized schema and resolvers
- Create, Read, Update, Delete functionality
- Detailed Searching by value
- Express server setup
- Apollo Server integration
- MongoDB integration
Create your schemas in the schemas folder, They then feed into the aggregated schema.js. Which is then used with apollo.js which creates a server. The server is then used within src.js to launch your express server as a graphql app.
Next we will create more useful TypeDefs and Resolvers
Able to use both Queries and Mutations (no db, not able to save)
Able to effictively search per field, can create, update and delete mutations (has db, can save)