Skip to content

feat: GraphQL client for mgpl-diagnostics/api - #6

Merged
BackStacked merged 1 commit into
mainfrom
claude/graphql-backend-fa2c1c
Oct 14, 2026
Merged

BackStacked merged 1 commit into
mainfrom
claude/graphql-backend-fa2c1c

Conversation

@BackStacked

@BackStacked BackStacked commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

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
  • Feature
  • Test data (ranges, units, prices)
  • Docs
  • Refactor / tooling

Screenshots

No UI (headless SDK).

Checklist

  • On a branch (not main)
  • npm run typecheck passes
  • npm run build passes (dist/index.js, dist/graphql.js, dist/react.js)
  • Docs updated (README, docs/graphql.md, docs/api.md, AGENTS.md, llms.txt)
  • Contract: mirrors feat: GraphQL backend over the kits, one endpoint api#1's schema. The api's test suite will validate these operations once it pins this version.
  • No real patient data, contact details or signatures

🤖 Generated with Claude Code

https://claude.ai/code/session_01BA5Vx77ihDsLiZpyg5duJV

createMgplGraphQLClient with a typed method for every query and mutation of
the api's single /graphql endpoint (138 operations, plain strings, zero
dependencies), MgplGraphQLError with stable codes, documentBlob and csvBlob.
New "/graphql" entry with the types flat; the main entry re-exports the
client and the types under Gql. Docs in docs/graphql.md. Version 1.1.0.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BA5Vx77ihDsLiZpyg5duJV
@BackStacked
BackStacked merged commit d973de3 into main Oct 14, 2026
1 check passed
@BackStacked
BackStacked deleted the claude/graphql-backend-fa2c1c branch October 14, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants