Repository navigation
feat: GraphQL client for mgpl-diagnostics/api - #6
Merged
Merged
Conversation
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
9 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: 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 asauth,users,organization,catalog,patients,doctors,bookings,samples,reports,invoices,books,gst,receivables,settlements,cash,bank,periods,exportsanddocuments.auth.loginkeeps the session token.MgplGraphQLErrorwith a stablecode.documentBlob/csvBlobturn 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."/graphql"entry with the types flat. The main entry re-exports the client, with the types under theGqlnamespace, because names likePatientalready exist for the HTTP API.docs/graphql.mdgains a Mermaid sequence diagram and a table mapping each method to its operation.Type
Screenshots
No UI (headless SDK).
Checklist
main)npm run typecheckpassesnpm run buildpasses (dist/index.js, dist/graphql.js, dist/react.js)docs/graphql.md,docs/api.md, AGENTS.md, llms.txt)🤖 Generated with Claude Code
https://claude.ai/code/session_01BA5Vx77ihDsLiZpyg5duJV