About quotes project
It can be hard to start with GraphQL and I struggled a lot with the first setup. I did several beginner mistakes and when I checked the internet I could find just some really basic examples. So I created an example project for everyone who wants to start with GraphQL.
The project itself is very easy. It is about IT quotes, so you have some author
and he / she can have one or more quotes
. The API then let a user ask for list of quotes or authors, filter and order them. Backend code is available in two languages: PHP and NodeJS.
If you are interested in frontend, then you can check this repository where is used React, Relay and TypeScript. Working application is available here.
Tech stack
PHP
NodeJS
Frontend
Database
Database has just two tables, author
and quote
. You can init the database with a script that is part of the project, or run migrations.
Table author
:
id | firstName | lastName |
---|---|---|
1 | John | Johnson |
2 | Martin | Fowler |
3 | Jason | Lengstorf |
Table quote
id | authorId | text |
---|---|---|
1 | 1 | First, solve the problem. Then, write the code. |
2 | 2 | Any fool can write code that a computer can understand. Good programmers write code that humans can understand. |
3 | 3 | If you stop learning, then the projects you work on are stuck in whatever time period you decided to settle. |
Tests
Project contains also couple of integration tests to check if the whole applicaton is working. If someone opens a pull request it runs a GitHub action, creates a database, run migrations and seed test data. Then run queries and check if the result is correct.