Skip to content

Test if the generated subgraph is compatible with Hive Console composition#8533

Merged
ardatan merged 3 commits intomasterfrom
test-subgraph
Apr 4, 2025
Merged

Test if the generated subgraph is compatible with Hive Console composition#8533
ardatan merged 3 commits intomasterfrom
test-subgraph

Conversation

@ardatan
Copy link
Copy Markdown
Owner

@ardatan ardatan commented Mar 21, 2025

  • Generate a subgraph SDL with mesh-compose -o subgraph.sdl --subgraph=petstore then compose it with Hive

Ref GW-226

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 21, 2025

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Introduced a configuration to integrate a pet store subgraph via an external API.
  • Tests
    • Added end-to-end tests to verify the subgraph's schema generation, composition accuracy, and query execution.

Walkthrough

The pull request introduces two new files within the pet store subgraph environment. One file establishes a GraphQL Mesh configuration that loads an OpenAPI subgraph using dynamic URL settings derived from command-line options. The other file provides an end-to-end test suite that deploys the pet store service in a Docker container, verifies schema composition (both against snapshots and via hive composition), and executes a GraphQL query to assert the service behavior.

Changes

File Path Change Summary
e2e/.../mesh.config.ts Introduces a new Mesh configuration for an OpenAPI subgraph, using loadOpenAPISubgraph and dynamic URL construction from command-line options.
e2e/.../petstore-subgraph.test.ts Adds an end-to-end test suite that deploys a Docker container, verifies schema composition through snapshot and hive composition tests, and executes a GraphQL query.

Sequence Diagram(s)

sequenceDiagram
  participant Runner as Test Runner
  participant Container as Petstore Container
  participant Config as Mesh Config
  participant Loader as OpenAPI Loader
  participant GraphQL as GraphQL Engine

  Runner->>Container: Start pet store container (Docker)
  Container-->>Runner: Service is ready
  Runner->>Config: Load composeConfig
  Config->>Loader: Call loadOpenAPISubgraph(url)
  Loader-->>Config: Return subgraph config
  Note right of Config: Compose subgraph schema dynamically

  Runner->>Runner: Execute schema composition & snapshot validation
  Runner->>GraphQL: Send GraphQL query (e.g., get pet by ID)
  GraphQL-->>Runner: Return query result
  Runner->>Runner: Validate query response and composition errors
Loading

Poem

I'm a rabbit hopping through the code lane,
Testing subgraphs with joy and no pain.
Mesh configs and Docker leaps so neat,
GraphQL queries make my heart beat.
Cheers to changes; may our tests never miss a beat!
🐰🚀

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

e2e/petstore-subgraph/petstore-subgraph.test.ts

Oops! Something went wrong! :(

ESLint: 9.22.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cbf6a92 and 1ade8ed.

📒 Files selected for processing (1)
  • e2e/petstore-subgraph/petstore-subgraph.test.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • e2e/petstore-subgraph/petstore-subgraph.test.ts
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: integration / node 22
  • GitHub Check: integration / node 20
  • GitHub Check: e2e / node v22
  • GitHub Check: integration / node 18
  • GitHub Check: e2e / node v20
  • GitHub Check: unit / node 22
  • GitHub Check: e2e / node v18
  • GitHub Check: unit / node 20
  • GitHub Check: unit / node 18
  • GitHub Check: check
  • GitHub Check: deployment

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 21, 2025

Apollo Federation Subgraph Compatibility Results

Federation 1 Support Federation 2 Support
_service🟢
@key (single)🟢
@key (multi)🟢
@key (composite)🟢
repeatable @key🟢
@requires🟢
@provides🟢
federated tracing🟢
@link🟢
@shareable🟢
@tag🟢
@override🟢
@inaccessible🟢
@composeDirective🟢
@interfaceObject🟢

Learn more:

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 21, 2025

💻 Website Preview

The latest changes are available as preview in:

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
e2e/petstore-subgraph/petstore-subgraph.test.ts (1)

38-46: Consider enhancing error reporting for composition failures.

While the current error handling logs each error, the thrown error message could be more specific to help with debugging.

if (compositionResult.errors) {
  for (const error of compositionResult.errors) {
    console.error(error);
  }
-  throw new Error('Composition failed');
+  throw new Error(`Composition failed: ${compositionResult.errors.map(e => e.message).join(', ')}`);
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aa90ba7 and 7920818.

⛔ Files ignored due to path filters (1)
  • e2e/petstore-subgraph/__snapshots__/petstore-subgraph.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (2)
  • e2e/petstore-subgraph/mesh.config.ts (1 hunks)
  • e2e/petstore-subgraph/petstore-subgraph.test.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: e2e / node v22
  • GitHub Check: e2e / node v20
  • GitHub Check: e2e / node v18
  • GitHub Check: check
  • GitHub Check: unit / node 22
  • GitHub Check: integration / node 20
  • GitHub Check: unit / node 20
  • GitHub Check: unit / node 18
  • GitHub Check: deployment
  • GitHub Check: integration / node 18
🔇 Additional comments (3)
e2e/petstore-subgraph/mesh.config.ts (1)

1-17: Configuration looks well-structured for the Petstore subgraph.

The mesh configuration correctly sets up an OpenAPI subgraph with appropriate source URL and endpoint construction using the service port. The comment on line 12-13 provides helpful context about why the endpoint needs to be manually specified.

e2e/petstore-subgraph/petstore-subgraph.test.ts (2)

5-15: Container setup looks good.

The test environment setup for the Petstore service using Swagger's official Docker image with appropriate health check is a solid approach for testing.


17-24: First test case correctly validates schema generation.

Using snapshot testing is an effective way to verify schema generation and detect unintended changes.

Comment thread e2e/petstore-subgraph/petstore-subgraph.test.ts
@ardatan ardatan merged commit 62e457e into master Apr 4, 2025
16 of 19 checks passed
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.

1 participant