We've explored the history. We've written some queries. We've created a schema. Now you're ready to create a fully functioning GraphQL service. In this chapter, we'll use Apollo Server 2.0, an open source solution from Meteor Development Group, to stand up a GraphQL server for the PhotoShare project. Along the way, we'll solidify a schema, write resolvers, incorporate a database, and add GitHub authorization to the project.
In this chapter, we'll build the PhotoShare API. The completed files for this chapter can be found at photo-share-api.
To run these files, simply:
- Go to the photo-share-api folder.
- Run
npm installon the folder. - Replace the values of the
.envfile with your unique variables.
DB_HOST=<YOUR_MONGODB_HOST>
CLIENT_ID=<YOUR_GITHUB_CLIENT_ID>
CLIENT_SECRET=<YOUR_GITHUB_CLIENT_SECRET>
- Run
npm startand open your browser tohttp://localhost:4000/playground.
Want to see the project running on Glitch instead?
Note: You'll still need to replace the values of the .env file with your unique variables, as shown in step 3.