Skip to content

Conversation

@rickstaa
Copy link
Member

Adds a new environment variable that lets developers temporarily override the subgraph endpoint with a Studio endpoint during local development.

Adds a new environment variable that lets developers temporarily
override the subgraph endpoint with a Studio endpoint during local
development.
@vercel
Copy link

vercel bot commented Dec 28, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
explorer-arbitrum-one Ready Ready Preview, Comment Dec 28, 2025 10:43am

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 adds a new environment variable NEXT_PUBLIC_SUBGRAPH_ENDPOINT that allows developers to temporarily override the subgraph endpoint during local development, useful for testing with Graph Studio sandbox endpoints.

Key Changes

  • Introduced NEXT_PUBLIC_SUBGRAPH_ENDPOINT environment variable for overriding subgraph URLs
  • Updated validation logic to make SUBGRAPH_KEY optional when the override is provided
  • Applied the override to all chain configurations (mainnet, goerli, arbitrum, arbitrum-goerli)

Reviewed changes

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

File Description
lib/chains.ts Added SUBGRAPH_URL_OVERRIDE constant and applied it as the primary subgraph URL source across all chain configurations, with updated validation
.env.example Documented the new optional NEXT_PUBLIC_SUBGRAPH_ENDPOINT environment variable with usage guidance

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

Comment on lines +26 to 29
if (!SUBGRAPH_KEY && !SUBGRAPH_URL_OVERRIDE) {
throw new Error(
`NEXT_PUBLIC_SUBGRAPH_API_KEY must be defined environment variables`
`NEXT_PUBLIC_SUBGRAPH_API_KEY (or NEXT_PUBLIC_SUBGRAPH_ENDPOINT override) must be defined environment variables`
);
Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

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

The validation logic allows either SUBGRAPH_KEY or SUBGRAPH_URL_OVERRIDE to be set, but when SUBGRAPH_URL_OVERRIDE is not provided, the code will still attempt to use SUBGRAPH_KEY in the URL template strings. This means if only SUBGRAPH_URL_OVERRIDE is set (without SUBGRAPH_KEY), the validation passes but undefined will be interpolated into the fallback URLs. Consider validating that SUBGRAPH_KEY is defined when SUBGRAPH_URL_OVERRIDE is not set.

Copilot uses AI. Check for mistakes.
if (!SUBGRAPH_KEY && !SUBGRAPH_URL_OVERRIDE) {
throw new Error(
`NEXT_PUBLIC_SUBGRAPH_API_KEY must be defined environment variables`
`NEXT_PUBLIC_SUBGRAPH_API_KEY (or NEXT_PUBLIC_SUBGRAPH_ENDPOINT override) must be defined environment variables`
Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

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

The error message uses plural "environment variables" when referring to a requirement that only one of the two variables needs to be defined. Consider changing to "must be defined as an environment variable" for grammatical correctness.

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.

2 participants