Repository navigation
feat: GraphQL backend over the kits, one endpoint - #1
Merged
Merged
Conversation
GraphQL Yoga on Fastify at POST /graphql (plus GET /health) with schema → controller → service layers over auth-kit, db-kit, catalog-kit, report-kit, invoice-kit, tally-kit and finance-kit as internal libraries: 137 queries and mutations for auth, organisation, catalog, lab, billing, books, finance and documents. Branch-aware permissions, tenant isolation, error codes, loaders, depth limit. End-to-end tests over HTTP on PostgreSQL and MongoDB, A-to-Z docs with Mermaid diagrams, examples, a generated API reference and a brief for the local agent. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BA5Vx77ihDsLiZpyg5duJV
This was referenced Oct 14, 2026
BackStacked
added a commit
to mgpl-diagnostics/client
that referenced
this pull request
Oct 14, 2026
## What and why
Before: the client could only call the report and invoice HTTP API
(`createMgplClient`). Nothing in it could reach patients, bookings,
billing, books or finance.
After: `createMgplGraphQLClient({ url: "/graphql" })` has a typed method
for every query and mutation of the new backend's single GraphQL
endpoint (mgpl-diagnostics/api#1), 138 operations in all. They are
grouped as `auth`, `users`, `organization`, `catalog`, `patients`,
`doctors`, `bookings`, `samples`, `reports`, `invoices`, `books`, `gst`,
`receivables`, `settlements`, `cash`, `bank`, `periods`, `exports` and
`documents`.
- `auth.login` keeps the session token.
- Errors throw `MgplGraphQLError` with a stable `code`.
- `documentBlob` / `csvBlob` turn rendered PDFs and CSV exports into
Blobs.
The package still has zero dependencies. The operations are plain
strings, and I validated all 138 against the api's schema: 0 invalid,
and every root field is covered.
How:
- `src/graphql/` holds the transport, the operations with their
fragments, the client and the types.
- There is a new `"/graphql"` entry with the types flat. The main entry
re-exports the client, with the types under the `Gql` namespace, because
names like `Patient` already exist for the HTTP API.
- `docs/graphql.md` gains a Mermaid sequence diagram and a table mapping
each method to its operation.
- README, AGENTS.md and llms files are updated, and the version goes to
1.1.0.
- The existing HTTP client is unchanged.
## Type
- [ ] Bug fix
- [x] Feature
- [ ] Test data (ranges, units, prices)
- [x] Docs
- [ ] Refactor / tooling
## Screenshots
No UI (headless SDK).
## Checklist
- [x] On a branch (not `main`)
- [x] `npm run typecheck` passes
- [x] `npm run build` passes (dist/index.js, dist/graphql.js,
dist/react.js)
- [x] Docs updated (README, `docs/graphql.md`, `docs/api.md`, AGENTS.md,
llms.txt)
- [x] Contract: mirrors mgpl-diagnostics/api#1's schema. The api's test
suite will validate these operations once it pins this version.
- [x] **No real patient data, contact details or signatures**
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01BA5Vx77ihDsLiZpyg5duJV
Co-authored-by: Claude <noreply@anthropic.com>
Pins @mgpl-diagnostics/client at the merge of client#6 (1.1.0). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BA5Vx77ihDsLiZpyg5duJV
BackStacked
added a commit
to mgpl-diagnostics/.github
that referenced
this pull request
Oct 14, 2026
## What and why Before: `protect-repos.mjs` did not know the new `api` repo, so running it would not require `ci` there. The org profile still listed api as "coming soon" and said PDFs use REST. After: `CHECKS` includes `api: ["ci"]`. The profile links the api (mgpl-diagnostics/api#1) and says everything goes through the one GraphQL endpoint, PDFs included. `llms-full.txt` is regenerated. Running `node scripts/protect-repos.mjs api` needs an org owner; it is step 1 of the api's `docs/LOCAL-AGENT-BRIEF.md`. ## Type - [ ] Bug fix - [ ] Feature - [ ] Test data (ranges, units, prices) - [x] Docs - [x] Refactor / tooling ## Checklist - [x] On a branch (not `main`) - [x] Docs updated (profile, llms-full.txt) - [x] **No real patient data, contact details or signatures** 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01BA5Vx77ihDsLiZpyg5duJV --- _Generated by [Claude Code](https://claude.ai/code/session_01BA5Vx77ihDsLiZpyg5duJV)_ Co-authored-by: Claude <noreply@anthropic.com>
7 of 11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Before: there was no backend. Each kit was a library, report-kit and invoice-kit had their own HTTP handlers, and db-kit held a partial GraphQL layer waiting to move.
After: this repo is the backend. One endpoint,
POST /graphql(GraphQL Yoga on Fastify, plusGET /health), serves 137 queries and mutations across:All seven kits are used as internal libraries behind controllers and services.
How:
src/schema(SDL per module) →src/controllers(authorize, map) →src/services(kit calls with(actor, input)) → kits.src/container.tsbuilds db-kit with finance-kit's posting hook, auth-kit on db-kit's stores (Redis when configured), and the services.docs/covers everything from A to Z with Mermaid diagrams (architecture, request sequence, state diagrams, ER diagram), plus runnable examples and an API reference generated from the schema and controllers (npm run docs:reference, checked in CI).docs/LOCAL-AGENT-BRIEF.mdlists the steps that need an org owner or a local machine: releases, package access, repo protection, the db-kit 2.0.0 cleanup, deployment and the CA review.kits.json(npm run kits), because not every kit is on the registry yet.Type
Screenshots
Nothing visual changes: documents are rendered by report-kit and invoice-kit, unchanged.
Checklist
main)npm run typecheckpasses🤖 Generated with Claude Code
https://claude.ai/code/session_01BA5Vx77ihDsLiZpyg5duJV