Skip to content

[WIP] Implement GraphQL schema completion and subscription support#4200

Open
Copilot wants to merge 1 commit intodevelopfrom
copilot/complete-graphql-schema-support
Open

[WIP] Implement GraphQL schema completion and subscription support#4200
Copilot wants to merge 1 commit intodevelopfrom
copilot/complete-graphql-schema-support

Conversation

Copy link
Contributor

Copilot AI commented Mar 13, 2026

Thanks for assigning this issue to me. I'm starting to work on it and will keep this PR's description up to date as I form a plan and make progress.

Original prompt

This section details on the original issue you should resolve

<issue_title>GraphQL Schema Completion and Subscription Support</issue_title>
<issue_description>### Context

This issue implements the roadmap item 'GraphQL Schema Completion and Subscription Support' for the api domain. It is sourced from the consolidated roadmap under 🟠 High Priority — Near-term (v1.5.0 – v1.8.0) and targets milestone v1.7.0.

Primary detail section: GraphQL Schema Completion and Subscription Support

Goal

Deliver the scoped changes for GraphQL Schema Completion and Subscription Support in src/api/ and complete the linked detail section in a release-ready state for v1.7.0.

Detailed Scope

GraphQL Schema Completion and Subscription Support

Priority: High
Target Version: v1.7.0

graphql.cpp implements a full parser and query executor but lacks mutation resolvers, schema introspection (__schema, __type), and subscription over WebSocket. Complete the schema to cover documents, graph edges, vector search, and geospatial queries; add subscription operation support backed by cdc::Changefeed.

Implementation Notes:

  • [x] Add SchemaRegistry class to graphql.cpp; auto-build from registered TypeDefinition objects at server start.
  • [x] Implement __schema and __type introspection resolvers; required by all major GraphQL clients (Apollo, Relay).
  • [x] Subscription transport: use Boost.Beast WebSocket upgrades; create graphql_ws_handler.cpp implementing the graphql-transport-ws protocol (not the legacy subscriptions-transport-ws).
  • [x] Wire cdc::Changefeed::subscribe(filter) as the event source for subscription { onChange(collection: "...") { ... } }. Implemented: Changefeed::subscribe(SubscriptionFilter, SubscriptionCallback) + SubscriptionHandle RAII type in changefeed.h/cpp; wired in GraphQLWsHandler::handleSubscribe() via extractOnChangeCollection().
  • [x] Enforce QueryLimits::maxSubscriptions per connection to prevent fan-out DoS.
  • [ ] In graphql.h, the Parser class explicitly documents "Not yet supported: Fragments, Directives, Inline fragments." Implement parseFragmentDefinition() and parseInlineFragment() in graphql.cpp — without fragment support, clients using Apollo's automatic persisted query fragments or any relay-style fragment composition will fail at parse time.
  • [ ] graphql.h::Parser::error() is documented as deprecated ("Deprecated: Use Result<T> return types instead of error() method") but the method still exists in the class definition. Remove it after migrating all call sites in graphql.cpp to return themis::Result<T> with structured ParseError objects to eliminate the dual error-reporting path.
  • [ ] Schema::introspect() in graphql.cpp only handles __schema and __type fields. The GraphQL June 2018 spec also requires __typename on every composite type, __Field, __InputValue, __EnumValue, and __Directive meta-types. Add these to Schema::introspect() so introspection-based tooling (code generators, schema diffing tools) works fully.
  • [ ] Executor::executeSelections() in graphql.cpp resolves fields serially in a range-for loop. For independent sibling fields that each invoke storage I/O, this means sequential round-trips. Add parallel field resolution via std::async or a small task graph; guard behind a QueryLimits::parallel_fields_enabled flag to allow gradual rollout.

Performance Targets:

  • GraphQL parse + validate + execute for a 10-field document query in < 2 ms (p99) under 500 concurrent HTTP/2 connections.
  • Subscription event delivery latency < 50 ms from Changefeed event emission to WebSocket frame sent.

API Sketch:

# New subscription type (graphql.cpp SchemaRegistry)
type Subscription {
  onChange(collection: String!, filter: ChangeFilter): ChangeEvent!
}

type ChangeEvent {
  sequence: Int!
  type: ChangeType!
  key: String!
  document: JSON
  timestampMs: Int!
}

Acceptance Criteria

  • Add SchemaRegistry class to graphql.cpp; auto-build from registered TypeDefinition objects at server start.
  • Implement __schema and __type introspection resolvers; required by all major GraphQL clients (Apollo, Relay).
  • Subscription transport: use Boost.Beast WebSocket upgrades; create graphql_ws_handler.cpp implementing the graphql-transport-ws protocol (not the legacy subscriptions-transport-ws).
  • Wire cdc::Changefeed::subscribe(filter) as the event source for subscription { onChange(collection: "...") { ... } }. Implemented: Changefeed::subscribe(SubscriptionFilter, SubscriptionCallback) + SubscriptionHandle RAII type in changefeed.h/cpp; wired in GraphQLWsHandler::handleSubscribe() via extractOnChangeCollection().
  • Enforce QueryLimits::maxSubscriptions per connection to prevent fan-out DoS.
  • In graphql.h, the Parser c...

💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

Copilot AI requested a review from makr-code March 13, 2026 19:33
@makr-code makr-code marked this pull request as ready for review March 14, 2026 06:14
@makr-code makr-code requested a review from Copilot March 14, 2026 06:14
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot wasn't able to review any files in this pull request.


You can also share your feedback on Copilot code review. Take the survey.

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 Schema Completion and Subscription Support

3 participants