Skip to content

Adds a temporary static build preview of Lab for faster iterations#7901

Draft
kamilkisiela wants to merge 2 commits intofeat/lab-query-planfrom
kamil-temp-lab-preview
Draft

Adds a temporary static build preview of Lab for faster iterations#7901
kamilkisiela wants to merge 2 commits intofeat/lab-query-planfrom
kamil-temp-lab-preview

Conversation

@kamilkisiela
Copy link
Copy Markdown
Contributor

@kamilkisiela kamilkisiela commented Mar 24, 2026

Steps:

  1. Open the file with ?endpoint=http://localhost:4000/graphql
    or with ?endpoint=https://mock-qp-response.theguild.workers.dev - it has mocked response

  2. Write config file:

supergraph:
  source: file
  path: bench/supergraph.graphql
log:
  level: info
query_planner:
  allow_expose: true
cors:
  enabled: true
  allow_any_origin: true
  policies: []
  1. cargo run

  2. Execute queries with header "hive-expose-query-plan": "true"

mskorokhodov and others added 2 commits March 24, 2026 12:59
Steps:
1. Open the file with `?endpoint=http://localhost:4000/graphql`

2. Write config file:

```yaml
supergraph:
source: file
path: bench/supergraph.graphql
log:
level: info
query_planner:
allow_expose: true
cors:
enabled: true
allow_any_origin: true
policies: []
```

3. `cargo run`

4. Execute queries with header `"hive-expose-query-plan": "true"`
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 introduces a new capability to generate a static HTML preview of the Lab application. This allows developers to quickly test and iterate on changes without needing a full development server, streamlining the feedback loop and improving the overall development experience for the Lab.

Highlights

  • New Build Script: Added a new build:static-preview script to package.json that first builds the project and then executes a Node.js script to generate a static preview.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/pr.yaml
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.

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
Copy Markdown
Contributor

@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 new script to generate a static HTML preview of the Laboratory, which streamlines the iteration process. The changes include adding a build:static-preview script to package.json and a new Node.js script build-static-preview.mjs that bundles the application and its dependencies into a single HTML file for easy local testing. The overall approach is sound for creating a self-contained preview.


const resolveDistPath = relativePath => path.resolve(distDirectory, relativePath);

const readRequiredText = relativePath => fs.readFile(resolveDistPath(relativePath), 'utf8');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The readRequiredText function is designed to fetch essential files for the static preview. However, it currently lacks error handling. If any of these files are missing from the dist directory, the script will fail abruptly without a clear message indicating which file caused the issue. Implementing a try-catch block would make the script more resilient and provide better diagnostic information in case of missing build artifacts.

const readRequiredText = async relativePath => {
  try {
    return await fs.readFile(resolveDistPath(relativePath), 'utf8');
  } catch (error) {
    console.error(`Error reading required file ${relativePath}:`, error);
    process.exit(1); // Exit with an error code
  }
};

document.head.appendChild(style);
}

new Function(payload.bundleSource)();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Using new Function(payload.bundleSource)() to execute the main JavaScript bundle, while functional, can introduce minor performance overhead and make debugging more challenging compared to directly embedding the script content within a <script> tag. For a static HTML file, directly inserting the bundle content is often a more straightforward and equally secure approach, assuming the bundleSource is trusted (which it is, coming from a local build).

const script = document.createElement('script');
script.textContent = payload.bundleSource;
document.body.appendChild(script);

@github-actions
Copy link
Copy Markdown
Contributor

🚀 Snapshot Release (alpha)

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

Package Version Info
@graphql-hive/laboratory 0.1.3-alpha-20260324124939-827754305917eb46d126da83453decc181fef271 npm ↗︎ unpkg ↗︎
@graphql-hive/render-laboratory 0.1.3-alpha-20260324124939-827754305917eb46d126da83453decc181fef271 npm ↗︎ unpkg ↗︎
hive 11.0.0-alpha-20260324124939-827754305917eb46d126da83453decc181fef271 npm ↗︎ unpkg ↗︎

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 24, 2026

🐋 This PR was built and pushed to the following Docker images:

Targets: build

Platforms: linux/amd64

Image Tag: 827754305917eb46d126da83453decc181fef271

@mskorokhodov mskorokhodov force-pushed the feat/lab-query-plan branch 4 times, most recently from cde3cb8 to 7f23520 Compare March 26, 2026 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants