Skip to content

Add persisted query and cost‑limit GraphQL plugins #126

Merged
Miracle656 merged 4 commits into
Miracle656:mainfrom
Emelie-Dev:main
Jun 24, 2026
Merged

Add persisted query and cost‑limit GraphQL plugins #126
Miracle656 merged 4 commits into
Miracle656:mainfrom
Emelie-Dev:main

Conversation

@Emelie-Dev

Copy link
Copy Markdown
Contributor

closes #115

Emelie-Dev and others added 3 commits June 24, 2026 17:21
Co-authored-by: aider (openrouter/openai/gpt-oss-120b:free) <aider@aider.chat>
@drips-wave

drips-wave Bot commented Jun 24, 2026

Copy link
Copy Markdown

@Emelie-Dev Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Miracle656 Miracle656 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plugins themselves look well-structured — a file-backed persisted-query store (getPersistedQuery + persistedQueryPlugin) and an AST-based costLimitPlugin with configurable limits — which is the right shape for #115. The blocker is that they have nothing to run against yet:

  1. There's no GraphQL server on main. src/graphql/ doesn't exist there — the server is in #124, which is still open (changes requested). So persistedQueryPlugin/costLimitPlugin aren't wired into anything and can't actually gate queries.

  2. This won't compile standalone. costLimit.ts imports from graphql, but graphql isn't a dependency in package.json on main (it's added by #124), and this PR doesn't add it — so typecheck/build will fail.

This is effectively stacked on #124. The cleanest path: get #124 merged first (it brings the graphql/Apollo deps + the server), then rebase this on top and wire the two plugins into that server (register them on the Apollo instance) so the persisted-query allowlist and cost/depth limits actually take effect. Add a test or two showing an over-cost query is rejected and a non-allowlisted query is blocked in prod mode.

Re-ping me once #124 lands and this is rebased + wired in. Thanks — the plugin code is a good start!

@Miracle656 Miracle656 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed — you've fully addressed the earlier feedback. This now stands on its own:

  • Added the deps (@apollo/server, graphql, @as-integrations/express4) so it compiles.
  • Built a real GraphQL server (src/graphql/server.ts) with a schema + resolvers wired to the actual data layer (queryAllTransfers/querySummary), mounted at app.use("/graphql", createGraphQLMiddleware()).
  • The guard plugins are wired into the Apollo instance (plugins: [persistedQueryPlugin, costLimitPlugin(...)]).
  • The tests are now meaningful — they verify an over-cost query is rejected, a non-allowlisted query is blocked in production, and an allowlisted persisted query runs. That's exactly #115's intent.

Merging. Closes #115.

Heads-up for coordination: this makes src/graphql/server.ts the canonical GraphQL server for wraith. #124 (GraphQL subscriptions) currently adds its own parallel server (src/api/graphql.ts) — I'll note there that it should rebase to add the subscription support onto this server rather than standing up a second one. Thanks for the thorough turnaround! 🎯

@Miracle656 Miracle656 merged commit 8f56cda into Miracle656:main Jun 24, 2026
1 check passed
Just-Bamford added a commit to Just-Bamford/wraith that referenced this pull request Jun 25, 2026
…cription tests

- Move src/api/graphql.ts to src/graphql/server.ts for canonical placement
- Replace broken test file with real subscription tests covering:
  * Subscription streaming (real-time event delivery)
  * Per-client filtering (contracts, senders, recipients)
  * Backpressure handling (queue management for slow consumers)
  * Amount formatting in subscription events
- Fix src/api.ts imports: move queryHostFnLogs from db (minimal changes only)
- Keep db.ts and api.ts changes minimal (no formatting churn)
- All 10 transfer subscription tests passing
- Ready for integration with canonical GraphQL server (pending Miracle656#126 merge)
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.

GraphQL persisted queries with depth & cost limiting

2 participants