Skip to content

Conversation

@enisdenjo
Copy link
Member

@enisdenjo enisdenjo commented Nov 27, 2025

Ref GW-531, ref GW-532

import { defineConfig } from '@graphql-hive/gateway';
import {
  unifiedGraphHandler,
  useQueryPlan,
} from '@graphql-hive/router-runtime';

export const gatewayConfig = defineConfig({
  unifiedGraphHandler,
  plugins: () => [
    useQueryPlan({
      // Query plan available callback
      onQueryPlan(queryPlan) {
        console.log(queryPlan);
      },
      // Expose the query plan in the result extensions
      expose: true,
      // or expose based on request
      expose: (req) => req.headers.get('hive-expose-query-plan') === 'true',
    }),
  ],
});

results in

{
  "data": {
    "hello": "world",
  },
  "extensions": {
    "queryPlan": {
      "kind": "QueryPlan",
      "node": {
        "kind": "Fetch",
        "operation": "{hello}",
        "operationKind": "query",
        "serviceName": "upstream",
      },
    },
  },
}

TODO

@gemini-code-assist
Copy link

Summary of Changes

Hello @enisdenjo, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request implements a new capability to include the GraphQL query plan directly within the extensions object of a GraphQL response. This provides developers with valuable insights into how their queries are executed, enabling better debugging and performance analysis. The functionality is designed to be configurable, allowing users to enable it via a context flag, ensuring it only impacts responses when explicitly desired.

Highlights

  • Query Plan Exposure: The pull request introduces a new feature that allows the GraphQL query plan to be exposed within the extensions field of the GraphQL response.
  • Context-Driven Activation: This feature is opt-in and can be activated by setting queryPlanInExtensions: true in the request context, typically triggered by a specific header like hive-expose-query-plan.
  • Core Logic Modification: The unifiedGraphHandler in packages/router-runtime/src/handler.ts has been updated to conditionally attach the query plan to the result extensions after execution.
  • New Test Coverage: A new test file packages/router-runtime/tests/handler.spec.ts has been added to ensure the correct functionality of exposing the query plan in extensions.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a feature to expose the query plan in GraphQL extensions, which is useful for debugging. The implementation for standard queries is correct, and it's accompanied by a good test case. I've provided a suggestion to improve the implementation to handle streaming responses (like subscriptions) and to make adding extensions more robust by merging with existing ones. I've also recommended adding a test case for subscriptions to ensure complete coverage of the new feature.

@theguild-bot
Copy link
Collaborator

theguild-bot commented Nov 27, 2025

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@graphql-tools/batch-delegate 10.0.6-alpha-8ea56a824441049703364ec2185ae13fb31495bb npm ↗︎ unpkg ↗︎
@graphql-tools/delegate 12.0.0-alpha-8ea56a824441049703364ec2185ae13fb31495bb npm ↗︎ unpkg ↗︎
@graphql-tools/federation 4.2.4-alpha-8ea56a824441049703364ec2185ae13fb31495bb npm ↗︎ unpkg ↗︎
@graphql-mesh/fusion-runtime 1.6.0-alpha-8ea56a824441049703364ec2185ae13fb31495bb npm ↗︎ unpkg ↗︎
@graphql-hive/gateway 2.1.20-alpha-8ea56a824441049703364ec2185ae13fb31495bb npm ↗︎ unpkg ↗︎
@graphql-hive/nestjs 2.0.25-alpha-8ea56a824441049703364ec2185ae13fb31495bb npm ↗︎ unpkg ↗︎
@graphql-hive/plugin-aws-sigv4 2.0.18-alpha-8ea56a824441049703364ec2185ae13fb31495bb npm ↗︎ unpkg ↗︎
@graphql-hive/plugin-opentelemetry 1.2.2-alpha-8ea56a824441049703364ec2185ae13fb31495bb npm ↗︎ unpkg ↗︎
@graphql-mesh/plugin-prometheus 2.1.6-alpha-8ea56a824441049703364ec2185ae13fb31495bb npm ↗︎ unpkg ↗︎
@graphql-hive/router-runtime 1.1.0-alpha-8ea56a824441049703364ec2185ae13fb31495bb npm ↗︎ unpkg ↗︎
@graphql-hive/gateway-runtime 2.3.6-alpha-8ea56a824441049703364ec2185ae13fb31495bb npm ↗︎ unpkg ↗︎
@graphql-tools/stitch 10.1.4-alpha-8ea56a824441049703364ec2185ae13fb31495bb npm ↗︎ unpkg ↗︎
@graphql-tools/stitching-directives 4.0.6-alpha-8ea56a824441049703364ec2185ae13fb31495bb npm ↗︎ unpkg ↗︎
@graphql-hive/gateway-testing 2.0.6-alpha-8ea56a824441049703364ec2185ae13fb31495bb npm ↗︎ unpkg ↗︎
@graphql-tools/wrap 11.1.0-alpha-8ea56a824441049703364ec2185ae13fb31495bb npm ↗︎ unpkg ↗︎

@theguild-bot
Copy link
Collaborator

theguild-bot commented Nov 27, 2025

🚀 Snapshot Release (Binary for Linux-ARM64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@theguild-bot
Copy link
Collaborator

theguild-bot commented Nov 27, 2025

🚀 Snapshot Release (Binary for Linux-X64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@theguild-bot
Copy link
Collaborator

theguild-bot commented Nov 27, 2025

🚀 Snapshot Release (Binary for macOS-ARM64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@theguild-bot
Copy link
Collaborator

theguild-bot commented Nov 27, 2025

🚀 Snapshot Release (Binary for Windows-X64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@theguild-bot
Copy link
Collaborator

theguild-bot commented Nov 27, 2025

🚀 Snapshot Release (Bun Docker Image)

The latest changes of this PR are available as image on GitHub Container Registry (based on the declared changesets):

ghcr.io/graphql-hive/gateway:2.1.20-alpha-8ea56a824441049703364ec2185ae13fb31495bb-bun

@theguild-bot
Copy link
Collaborator

theguild-bot commented Nov 27, 2025

🚀 Snapshot Release (Node Docker Image)

The latest changes of this PR are available as image on GitHub Container Registry (based on the declared changesets):

ghcr.io/graphql-hive/gateway:2.1.20-alpha-8ea56a824441049703364ec2185ae13fb31495bb

@theguild-bot
Copy link
Collaborator

theguild-bot commented Nov 27, 2025

🚀 Snapshot Release (Binary for macOS-X64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@enisdenjo enisdenjo merged commit 8ff2e47 into main Nov 28, 2025
77 checks passed
@enisdenjo enisdenjo deleted the qp branch November 28, 2025 17:38
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