Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nareshbhatia/graphql-bookstore
Example demonstrating the use of GraphQL to implement a rich domain with multiple entities and relationships
https://github.com/nareshbhatia/graphql-bookstore
Last synced: about 4 hours ago
JSON representation
Example demonstrating the use of GraphQL to implement a rich domain with multiple entities and relationships
- Host: GitHub
- URL: https://github.com/nareshbhatia/graphql-bookstore
- Owner: nareshbhatia
- Created: 2018-12-09T00:02:22.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-05-27T20:51:20.000Z (over 3 years ago)
- Last Synced: 2023-11-07T19:07:10.785Z (almost 1 year ago)
- Language: TypeScript
- Size: 4.67 MB
- Stars: 121
- Watchers: 4
- Forks: 19
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
GraphQL Bookstore
=================
\[This is the code repo for my [GraphQL tutorial](https://medium.com/naresh-bhatia/graphql-concepts-i-wish-someone-explained-to-me-a-year-ago-514d5b3c0eab) on Medium.\]Most GraphQL tutorials use simplistic examples to demonstrate its capabilities. Unfortunately, when we start building real applications, we run into complexities that these tutorials do not address. This repo demonstrates the use of GraphQL to implement a rich domain with multiple entities and relationships. We use the [Apollo GraphQL](https://www.apollographql.com/) tools and libraries for this implementation.
1. Our example uses a simple book domain containing 3 entities and 2 relationships.
2. We demonstrate real-time updates on the client using GraphQL subscriptions.Here's the domain model of our book domain:
![Domain Model](assets/bookstore-domain-model.png)
- Every book has a publisher, a publisher may publish multiple books (one-to-many relationship).
- A book may have one or more authors, an author may write multiple books (many-to-many relationship).Here's the front-end of the application. It is intentionally designed to show all the entities and relationships on one page. This allows us to demonstrate several features of the Apollo Cache, for example, how normalization keeps application data consistent across multiple components.
![Screen Shot](assets/screen-shot.png)
We have one server implementation that uses Apollo:
1. [Apollo Bookstore Server](./apollo-bookstore-server)We have two client implementations using React Apollo:
1. [Apollo Bookstore Client](./apollo-bookstore-client)
2. [Apollo Bookstore Client with React Hooks](./apollo-bookstore-client-with-hooks)