Skip to content

enhancement: lab to fetch schema if no introspection provided in inte…#7888

Open
mskorokhodov wants to merge 1 commit intomainfrom
enhancement/lab-schema-introspection
Open

enhancement: lab to fetch schema if no introspection provided in inte…#7888
mskorokhodov wants to merge 1 commit intomainfrom
enhancement/lab-schema-introspection

Conversation

@mskorokhodov
Copy link
Copy Markdown
Collaborator

@mskorokhodov mskorokhodov commented Mar 19, 2026

…rvall

Background

Description

If schema introspection isn't provided as property to Laboratory, lab will start interval to fetch schema every second.

Screen.Recording.2026-03-20.at.10.00.06.mov

Checklist

  • Input validation
  • Output encoding
  • Authentication management
  • Session management
  • Access control
  • Cryptographic practices
  • Error handling and logging
  • Data protection
  • Communication security
  • System configuration
  • Database security
  • File management
  • Memory management
  • Testing

@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 enhances the Laboratory component by introducing dynamic GraphQL schema fetching. It ensures that the editor always has the most current schema information, either by polling an endpoint if no static introspection is provided or if the endpoint changes, or by efficiently updating the Monaco editor's schema configuration. This improves the user experience by providing accurate auto-completion and validation without requiring a full page refresh.

Highlights

  • Dynamic Schema Fetching: Implemented automatic polling for GraphQL schema introspection if no default introspection is provided or if the current endpoint differs from the default, ensuring the Laboratory always has an up-to-date schema.
  • Monaco Editor Schema Updates: Refactored the Monaco GraphQL editor integration to dynamically update the schema configuration using setSchemaConfig when new introspection data becomes available, improving editor responsiveness and accuracy.
  • Code Cleanup: Removed several console.log statements from various files, cleaning up the codebase.
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.

@mskorokhodov mskorokhodov force-pushed the enhancement/lab-schema-introspection branch from 3ccf2f2 to a122b2d Compare March 19, 2026 19:57
@mskorokhodov mskorokhodov requested a review from n1ru4l March 19, 2026 19:57
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

The pull request introduces an enhancement to fetch the schema if no introspection is provided, and refactors the Monaco GraphQL API initialization to reuse the API instance. It also removes some debug console.log statements. Overall, the changes improve the functionality and cleanliness of the code. However, there are a couple of areas that need attention regarding dependency arrays in useEffect and the aggressiveness of a polling interval.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 19, 2026

🚀 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-20260323212628-4f1e2f0165d974d72c083bd431675b0ae6741367 npm ↗︎ unpkg ↗︎
@graphql-hive/render-laboratory 0.1.3-alpha-20260323212628-4f1e2f0165d974d72c083bd431675b0ae6741367 npm ↗︎ unpkg ↗︎
hive 10.2.1-alpha-20260323212628-4f1e2f0165d974d72c083bd431675b0ae6741367 npm ↗︎ unpkg ↗︎

@mskorokhodov mskorokhodov force-pushed the enhancement/lab-schema-introspection branch from a122b2d to 77fb919 Compare March 19, 2026 20:00
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 19, 2026

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

Targets: build

Platforms: linux/amd64

Image Tag: 4f1e2f0165d974d72c083bd431675b0ae6741367

@mskorokhodov mskorokhodov force-pushed the enhancement/lab-schema-introspection branch from 77fb919 to 0551512 Compare March 20, 2026 10:15

abortController = new AbortController();
void fetchSchema(abortController.signal);
}, 5000);
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.

An arbitrary timeout of 5 seconds seems pretty restrictive for bigger GraphQL schemas, that might take a longer time to load or slow network connections. Instead, to me it seems like it might be a better approach to wait for the call to fail or complete, before scheduling the next retry interval.

@mskorokhodov mskorokhodov force-pushed the enhancement/lab-schema-introspection branch from 0551512 to f3bbdec Compare March 20, 2026 10:46
@n1ru4l
Copy link
Copy Markdown
Contributor

n1ru4l commented Mar 20, 2026

What is the behaviour if the introspection is explicitly disabled on the server, would that be detected and the polling is stopped? Do we provide some visual feedback to the user bout that scenario?

@mskorokhodov mskorokhodov force-pushed the enhancement/lab-schema-introspection branch from f3bbdec to 4f1e2f0 Compare March 23, 2026 21:25
@mskorokhodov
Copy link
Copy Markdown
Collaborator Author

mskorokhodov commented Mar 23, 2026

What is the behaviour if the introspection is explicitly disabled on the server, would that be detected and the polling is stopped? Do we provide some visual feedback to the user bout that scenario?

Yeap, added logic to not fetch same endpoint again in case of failed response, will create new interval on endpoint update

Uploading Screen Recording 2026-03-23 at 23.26.51.mov…

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