Concept for an Apollo full-stack example app that demonstrates all of the important concepts
- Routes and data loading
- Server side rendering and store hydration
- Merging data from multiple backends/APIs
- Authentication and basic security
- Mutations - updating and inserting items
- Developer tool integrations, like
eslint-plugin-graphql
- One place where there is reactivity/streaming data (nice to have)
As new patterns emerge in Apollo development, we should add them to this app.
gclone- It will have functionality where users can view & vote on repos.
There are three views:
- The home page feed, which is a ranked list of repositories
- A page to submit a new repository
- A repository page, with comments
Does it demonstrate all of the required features above?
- Routes and data loading? Yes, it has multiple pages which require different data.
- SSR/hydration? Yes, the front page should load fast.
- Merging data? Yes, this will merge upvote and comment data from a local database with repository information from GitHub.
- Auth and basic security? Yes, it will have GitHub login, and security so that people can only post comments when logged in, and everyone can only vote once per repo.
- Mutations: Submitting a new repo, voting, and commenting.
- Dev tools: Yes
- Reactivity: we can reactively update the vote count on the repository page via a websocket or poll.
- React
- React router
- Webpack
- Babel
- Redux
- Passport for login
Make sure you have Node v4.x.x installed (app has been tested with node v4.4.5)
> mkdir gclone && cd $_
> git clone https://github.com/Shwetank30/gclone.git
> npm install
Seed the application
> npm run migrate
> npm run seed
- Under your Github profile dropdown, choose 'Settings'
- On the left nav, choose 'OAuth applications'
- Choose the 'Developer Applications' tab at the top of the page
- Click 'Register a new application' button
- Register your application like below
- Click 'Register application' button
On the following page, grab:
- Client ID
- Client Secret
Set your Client ID and Client Secret Environment variables:
> GITHUB_CLIENT_ID="your Client ID"; export GITHUB_CLIENT_ID
> GITHUB_CLIENT_SECRET="your Client Secret" export GITHUB_CLIENT_SECRET
> npm run start
- Open the client at http://localhost:5200
- Click "Log in with GitHub" in the upper right corner
- You'll be presented with the seed items in the app
Click the green Submit button and add repo with the username/repo-name pattern.
Review the new item, up vote it and visit the repo via the link.
The server will run on port 3010. You can access the server's GraphiQL UI at http://localhost:3010/graphql