Architecture
Learner Model GQL follows a Microservices architecture style while leveraging GraphQL, the client-side of the project interacts with a single GraphQL API gateway, which orchestrates the different GraphQL microservices based on the request query.
Schema Stitching
The GraphQL services design and API gateway rely on schema stitching, using the GraphQL Tools library @graphql-tools/stitch.
Some critical designs to be followed to do the schema stitching are:
- Every entity to be extended by more than a single service needs a unique "id" field
- Every service that extends an entity needs a standardized query that accepts a list of ids and returns a list of the requested entities in the same order as the "ids" parameter. If any of the requested entities is not found, the query must fail.
Services
Current services
- Actions | packages/services/actions
- Content | packages/services/content
- Domain | packages/services/domain
- Projects | packages/services/projects
- State | packages/services/state
- Users | packages/services/users
Ecosystem
All the services are currently made using TypeScript with Node.js,
but there isn't any specific requirement for new services to be made the same way, new GraphQL services could be made with different ecosystems,
like Go or Rust, and just work by following the mentioned design constraints of Schema Stitching
.
Important libraries
-
GraphQL EZ - graphql-ez.com - GraphQL API Framework, with support for multiple web frameworks and the latest GraphQL features.
Which also relies on:
- graphql-js - github.com/graphql/graphql-js - Reference implementation of GraphQL for JavaScript
- Envelop - envelop.dev - GraphQL API plugin system
-
Fastify - fastify.io - Fast and low overhead web framework for Node.js
-
Prisma Client - prisma.io/client - Intuitive Database Client for TypeScript and Node.js
-
bob-tsm - github.com/PabloSzx/bob-esbuild/tree/main/packages/bob-tsm - TypeScript Module Loader, automatically running TypeScript modules seamlessly
-
GraphQL Tools - graphql-tools.com - A set of utilities for faster development of GraphQL Schemas
-
GraphQL Code Generator - graphql-code-generator.com - TypeScript code generator from GraphQL schemas for full type-safety.