-
Notifications
You must be signed in to change notification settings - Fork 16
chore: allow subgraph endpoint override via env var #468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Adds a new environment variable that lets developers temporarily override the subgraph endpoint with a Studio endpoint during local development.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this 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_ENDPOINTenvironment variable for overriding subgraph URLs - Updated validation logic to make
SUBGRAPH_KEYoptional 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.
| 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` | ||
| ); |
Copilot
AI
Dec 28, 2025
There was a problem hiding this comment.
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.
| 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` |
Copilot
AI
Dec 28, 2025
There was a problem hiding this comment.
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.
Adds a new environment variable that lets developers temporarily override the subgraph endpoint with a Studio endpoint during local development.