Skip to content
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

Subgraph protocol #470

Merged
merged 5 commits into from
Oct 20, 2024
Merged

Subgraph protocol #470

merged 5 commits into from
Oct 20, 2024

Conversation

Corantin
Copy link
Contributor

@Corantin Corantin commented Oct 18, 2024

This pull request introduces several changes to the apps/web/configs/chains.tsx file, focusing on the handling of subgraph URLs and improving the robustness of subgraph queries. Key changes include the addition of a new utility function to generate subgraph URLs, updates to the chainConfigMap, and enhancements to the subgraph query hooks to handle errors more gracefully.

Changes to subgraph URL handling:

  • Added an optional publishedSubgraphUrl property to the ChainData type. (apps/web/configs/chains.tsx)
  • Introduced the getSubgraphUrls function to generate subgraph URLs, including the published subgraph URL if available. (apps/web/configs/chains.tsx)
  • Updated chainConfigMap entries to use the new getSubgraphUrls function for generating subgraph URLs. (apps/web/configs/chains.tsx) [1] [2] [3] [4] [5]

Enhancements to subgraph query hooks:

  • Modified useSubgraphQuery to attempt fetching data from the publishedSubgraphUrl first, and fall back to the regular subgraph URL if an error occurs. (apps/web/hooks/useSubgraphQuery.ts)
  • Updated useSubgraphQueryMultiChain to handle multiple chain configurations and retry fetching from the publishedSubgraphUrl if the initial fetch fails. (apps/web/hooks/useSubgraphQueryMultiChain.ts) [1] [2]

Other changes:

  • Updated the subgraph version in subgraph.json to 0.1.1 for production. (apps/web/configs/subgraph.json)

♻️ Refactored subgraph URL generation

- Introduced a new function to generate subgraph URLs
- Added error handling for fetching data from published subgraphs, with fallback to hosted ones
- Updated the use of this function across multiple files
- Included the ability to specify a publishedSubgraphUrl in chain configuration
- Bumped up the production version of the subgraph in config file
Copy link

vercel bot commented Oct 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
gardens-v2 🛑 Canceled (Inspect) Oct 20, 2024 11:50pm

@Corantin Corantin changed the title ♻️ Refactored subgraph URL generation Subgraph protocol Oct 18, 2024
@Corantin Corantin linked an issue Oct 18, 2024 that may be closed by this pull request
@Corantin
Copy link
Contributor Author

!ai

Copy link

Gemini Code Review encountered an error. View the run here.

See Code Review by Gemini AI step as it may still contains some review before failing.

- Replaced the direct environment variable access for fetching the Subgraph URL with a function call to `getConfigByChain`.
- This change enhances code maintainability and readability by centralizing configuration data retrieval.
@Corantin Corantin merged commit 54b3ca0 into dev Oct 20, 2024
1 of 3 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.

Migrate to TheGraph protocol
1 participant