A guide to help developers onboard to the Button stack by building a simple todo app.
The goals are:
-
Create a working todo app in order to learn by discovery, decoupled from any project-specific context in which this stack may be used.
-
Make a series of draft pull requests against the main branch for the purposes of demonstration / archive and peer review.
Previous solutions by other developers are accessible in this repository's pull requests; viewer's discretion is advised 😉.
Ensure that:
- Postgres is installed.
- Sqitch is installed (requires a working Perl 5 installation).
- Node is installed.
- This repository has been cloned, or forked somewhere that you have push permissions and can share your solutions with your team.
- For each step, you have checked out a new branch with your name as a prefix:
myname/this-step
- After completing a step, create a draft pull request with the previous step's branch as the base; these pull requests are not intended to be merged.
- Request review from someone who can help.
As a user, I can:
- View all todos
- Mark existing todos as completed
- Add new todos to the list
- See the list in the same state between browser refreshes
- Ensure a Postgres service is running.
- Create a new database for the purpose of this project.
- Create a
schema/
folder for database things, and from there initialize a new Sqitch project. - Use Sqitch to create a new schema,
todo_app
in the project database.
* Note: Entities' dependencies (such as a table that depends on a schema) can be expressed to Sqitch at the time of creation using the --requires
flag. These will show up n the sqitch.plan
in square brackets next to the name of the created entity. Sqitch will ensure dependencies are deployed first.
- Use Sqitch to create a table in this schema* (see note) with the following attributes:
id
task
completed
date_created
date_updated
Pro tip: Insert some seed data into this table for testing the next few steps.
Postgraphile can generate a GraphQL API based on our Postgres database, so for the sake of simplicity for this project, there's no need to build a Node backend.
npm init
to initialize apackage.json
for the project.- Install Postgraphile and run it pointing at the project's database.
- Open the Graphiql (a graphical UI for GraphQL queries) instance that should be live at
/graphiql
on localhost once Postgraphile is running. - Confirm that GraphQL is introspecting your Postgres schema by querying the todos you inserted in the previous step.
- Use Create React App with Typescript to bootstrap the client:
npx create-react-app client --template typescript
- Add Relay to the client.
- Build
TodoList
andTodoListItem
components, each using a Relay fragment for data. - Ensure that data requirements for each component are specified using GraphQL. Using Graphiql can help you refine this.
Make a simple mutation-based component for adding new todos to the list.
Use Jest to test client side components.