Generate GraphQL Queries from Subgraph Hashes with AI
This Dify workflow acts as an intelligent GraphQL query generator for blockchain subgraphs. It takes a user's question and a subgraph IPFS hash, leverages OpenAI to construct a precise query, and automatically executes it to fetch on-chain data. The workflow includes a robust multi-retry mechanism, ensuring the highest possible success rate in data retrieval for your Web3 development needs.

Workflow Overview
What is this?
- This workflow is a powerful tool for developers that automates the generation of GraphQL queries. By providing a subgraph IPFS hash and a question in natural language, the system uses an AI model (GPT-4o-mini) to intelligently construct the correct GraphQL query and fetch the desired on-chain data.
What problem does it solve?
- Tired of manually inspecting subgraph schemas and writing complex, trial-and-error GraphQL queries? This workflow eliminates that time-consuming and error-prone process, especially when dealing with unfamiliar or poorly documented subgraphs.
What will you get?
- Accelerate your Web3 development by instantly generating queries instead of writing them by hand. Increase data retrieval reliability with an automated, multi-attempt retry logic across different subgraphs. Reduce development friction by interacting with blockchain data using plain English questions. Simplify your dApp or analytics workflow by abstracting away the complexity of GraphQL syntax.
How to Use
Prerequisites
Setup Steps
Import the Workflow
Download the workflow's YML file and import it into your Dify application.
Configure LLM Provider
Navigate to the LLM nodes within the workflow (e.g., 'Generate GraphQL Query') and ensure your OpenAI provider is selected and the API key is correctly configured.
Set Up Input Variables
In the 'Start' node, review the input variables. The primary inputs you will use are `subgraph_ipfs_hash` and `question`. The other `subgraph_ipfs_hash_2` and `_3` are for the retry logic.
Run and Test
Save the workflow and run it with a test case. Provide a valid subgraph IPFS hash and a clear question to verify that the workflow executes successfully and returns the expected data.
Pro Tips
Information
- Published date8/15/2025
- Last updated8/15/2025