Skip to content

Conversation

@enisdenjo
Copy link
Member

@enisdenjo enisdenjo commented Oct 24, 2025

import { createGatewayTester } from '@graphql-hive/gateway-testing';

{
  // will be disposed of on scope exit
  await using gw = createGatewayTester({
    subgraphs: [
      {
        name: 'helloer',
        schema: {
          typeDefs: /* GraphQL */ `
            type Query {
              hello: String
            }
          `,
          resolvers: {
            Query: {
              hello: () => 'world',
            },
          },
        },
      },
    ],
    // your gateway config for testing
    plugins: () => [
      // your plugins for testing
    ],
  });

  // gateway is running in supergraph mode

  const result = await gw.execute({
    query: /* GraphQL */ `
      query {
        hello
      }
    `,
  });

  // the complete lifecycle of the gateway has been run

  console.log(result); // { data: { hello: 'world' } }
}

TODO

  • Supergraph mode
  • Subgraph mode
  • Proxy mode
  • Explicit resource management (await using gw = createGatewayTester())
  • dispose() as alternative to await using
  • Hive Gateway Tester documentation console#7180
  • Refactor internal tests to use the tester
    • A good chunk was refactored, but not all to avoid wasting time

@theguild-bot
Copy link
Collaborator

theguild-bot commented Oct 24, 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.2-alpha-f555607556652b06a7b1e5c992d6d87454afc1e5 npm ↗︎ unpkg ↗︎
@graphql-tools/delegate 11.0.2-alpha-f555607556652b06a7b1e5c992d6d87454afc1e5 npm ↗︎ unpkg ↗︎
@graphql-tools/federation 4.0.6-alpha-f555607556652b06a7b1e5c992d6d87454afc1e5 npm ↗︎ unpkg ↗︎
@graphql-mesh/fusion-runtime 1.2.6-alpha-f555607556652b06a7b1e5c992d6d87454afc1e5 npm ↗︎ unpkg ↗︎
@graphql-hive/gateway 2.1.11-alpha-f555607556652b06a7b1e5c992d6d87454afc1e5 npm ↗︎ unpkg ↗︎
@graphql-hive/logger 1.0.7-alpha-f555607556652b06a7b1e5c992d6d87454afc1e5 npm ↗︎ unpkg ↗︎
@graphql-hive/nestjs 2.0.16-alpha-f555607556652b06a7b1e5c992d6d87454afc1e5 npm ↗︎ unpkg ↗︎
@graphql-hive/plugin-aws-sigv4 2.0.11-alpha-f555607556652b06a7b1e5c992d6d87454afc1e5 npm ↗︎ unpkg ↗︎
@graphql-hive/plugin-opentelemetry 1.0.13-alpha-f555607556652b06a7b1e5c992d6d87454afc1e5 npm ↗︎ unpkg ↗︎
@graphql-mesh/plugin-prometheus 2.0.14-alpha-f555607556652b06a7b1e5c992d6d87454afc1e5 npm ↗︎ unpkg ↗︎
@graphql-hive/gateway-runtime 2.1.10-alpha-f555607556652b06a7b1e5c992d6d87454afc1e5 npm ↗︎ unpkg ↗︎
@graphql-tools/stitch 10.0.3-alpha-f555607556652b06a7b1e5c992d6d87454afc1e5 npm ↗︎ unpkg ↗︎
@graphql-tools/stitching-directives 4.0.2-alpha-f555607556652b06a7b1e5c992d6d87454afc1e5 npm ↗︎ unpkg ↗︎
@graphql-hive/gateway-testing 1.0.0-alpha-f555607556652b06a7b1e5c992d6d87454afc1e5 npm ↗︎ unpkg ↗︎
@graphql-mesh/transport-common 1.0.7-alpha-f555607556652b06a7b1e5c992d6d87454afc1e5 npm ↗︎ unpkg ↗︎
@graphql-mesh/transport-http 1.0.7-alpha-f555607556652b06a7b1e5c992d6d87454afc1e5 npm ↗︎ unpkg ↗︎
@graphql-mesh/transport-http-callback 1.0.7-alpha-f555607556652b06a7b1e5c992d6d87454afc1e5 npm ↗︎ unpkg ↗︎
@graphql-mesh/transport-ws 2.0.7-alpha-f555607556652b06a7b1e5c992d6d87454afc1e5 npm ↗︎ unpkg ↗︎
@graphql-tools/wrap 11.0.2-alpha-f555607556652b06a7b1e5c992d6d87454afc1e5 npm ↗︎ unpkg ↗︎

@theguild-bot
Copy link
Collaborator

theguild-bot commented Oct 24, 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 Oct 24, 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 Oct 24, 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 Oct 24, 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.11-alpha-f555607556652b06a7b1e5c992d6d87454afc1e5

@theguild-bot
Copy link
Collaborator

theguild-bot commented Oct 24, 2025

🚀 Snapshot Release (Binary for macOS-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 Oct 24, 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.11-alpha-f555607556652b06a7b1e5c992d6d87454afc1e5-bun

@theguild-bot
Copy link
Collaborator

theguild-bot commented Oct 24, 2025

🚀 Snapshot Release (Binary for Windows-X64)

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

Download

@enisdenjo enisdenjo marked this pull request as ready for review October 27, 2025 16:20
Copilot AI review requested due to automatic review settings October 27, 2025 16:20
@enisdenjo enisdenjo merged commit 357d931 into main Oct 27, 2025
19 checks passed
@enisdenjo enisdenjo deleted the gateway-testing branch October 27, 2025 16:20
Copy link
Contributor

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.

Pull Request Overview

This PR introduces a new testing package (@graphql-hive/gateway-testing) that provides utilities for testing Hive Gateway configurations, supporting supergraph, subgraph composition, and proxy modes with explicit resource management through await using. The PR also refactors existing internal tests to use the new tester, demonstrating its usage across different testing scenarios.

Key changes:

  • New @graphql-hive/gateway-testing package with createGatewayTester utility
  • Support for explicit resource management (await using and manual dispose())
  • Refactored tests across multiple packages to use the new testing utilities

Reviewed Changes

Copilot reviewed 12 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/testing/src/index.ts Core implementation of the gateway tester with support for supergraph, subgraph, and proxy modes
packages/testing/package.json Package configuration for the new testing utilities
packages/runtime/tests/upstream-timeout.test.ts Refactored to use createGatewayTester instead of direct runtime creation
packages/runtime/tests/subscriptions.test.ts Simplified subscription tests using the new tester utilities
packages/runtime/tests/propagateHeaders.spec.ts Refactored header propagation tests with new testing approach
packages/runtime/src/types.ts Exported previously internal interfaces for use in testing package
packages/plugins/prometheus/tests/prometheus.spec.ts Updated Prometheus plugin tests to use gateway tester
packages/plugins/hmac-upstream-signature/tests/hmac-upstream-signature.spec.ts Simplified HMAC signature tests with new testing utilities
packages/plugins/aws-sigv4/tests/aws-sigv4-outgoing.test.ts Refactored AWS SigV4 outgoing request tests
packages/plugins/aws-sigv4/tests/aws-sigv4-incoming.test.ts Updated AWS SigV4 incoming request tests with minor header type correction
.changeset/dry-numbers-deliver.md Changeset documenting the new testing package
.changeset/@graphql-hive_plugin-aws-sigv4-1625-dependencies.md Changeset documenting AWS SDK dependency update

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

'content-type': 'application/json',
Host: 'sigv4examplegraphqlbucket.s3-eu-central-1.amazonaws.com',
'Content-Length': 30,
'Content-Length': '30',
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

The Content-Length header value has been changed from a number (30) to a string ('30'). This may indicate a breaking change in how headers are handled. Verify that the gateway and AWS SigV4 signing logic correctly handle Content-Length as a string, as HTTP headers are typically strings but the signature calculation might expect specific formatting.

Copilot uses AI. Check for mistakes.
'content-type': 'application/json',
Host: 'sigv4examplegraphqlbucket.s3-eu-central-1.amazonaws.com',
'Content-Length': 30,
'Content-Length': '30',
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

The Content-Length header value has been changed from a number (30) to a string ('30'). This may indicate a breaking change in how headers are handled. Verify that the gateway and AWS SigV4 signing logic correctly handle Content-Length as a string, as HTTP headers are typically strings but the signature calculation might expect specific formatting.

Copilot uses AI. Check for mistakes.
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.

4 participants