|
2 | 2 | title: حول The Graph
|
3 | 3 | ---
|
4 | 4 |
|
5 |
| -هذه الصفحة ستشرح The Graph وكيف يمكنك أن تبدأ. |
6 |
| - |
7 | 5 | ## What is The Graph?
|
8 | 6 |
|
9 |
| -The Graph is a decentralized protocol for indexing and querying blockchain data. The Graph makes it possible to query data that is difficult to query directly. |
| 7 | +The Graph is a powerful decentralized protocol that enables seamless querying and indexing of blockchain data. It simplifies the complex process of querying blockchain data, making dapp development faster and easier. |
| 8 | + |
| 9 | +## Understanding the Basics |
| 10 | + |
| 11 | +Projects with complex smart contracts such as [Uniswap](https://uniswap.org/) and NFTs initiatives like [Bored Ape Yacht Club](https://boredapeyachtclub.com/) store data on the Ethereum blockchain, making it very difficult to read anything other than basic data directly from the blockchain. |
| 12 | + |
| 13 | +### Challenges Without The Graph |
| 14 | + |
| 15 | +In the case of the example listed above, Bored Ape Yacht Club, you can perform basic read operations on [the contract](https://etherscan.io/address/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d#code). You can read the owner of a certain Ape, read the content URI of an Ape based on their ID, or read the total supply. |
| 16 | + |
| 17 | +- This can be done because these read operations are programmed directly into the smart contract itself. However, more advanced, specific, and real-world queries and operations like aggregation, search, relationships, and non-trivial filtering, **are not possible**. |
| 18 | + |
| 19 | +- For instance, if you want to inquire about Apes owned by a specific address and refine your search based on a particular characteristic, you would not be able to obtain that information by directly interacting with the contract itself. |
| 20 | + |
| 21 | +- To get more data, you would have to process every single [`transfer`](https://etherscan.io/address/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d#code#L1746) event ever emitted, read the metadata from IPFS using the Token ID and IPFS hash, and then aggregate it. |
| 22 | + |
| 23 | +### Why is this a problem? |
| 24 | + |
| 25 | +It would take **hours or even days** for a decentralized application (dapp) running in a browser to get an answer to these simple questions. |
| 26 | + |
| 27 | +Alternatively, you have the option to set up your own server, process the transactions, store them in a database, and create an API endpoint to query the data. However, this option is [resource intensive](/network/benefits/), needs maintenance, presents a single point of failure, and breaks important security properties required for decentralization. |
| 28 | + |
| 29 | +Blockchain properties, such as finality, chain reorganizations, and uncled blocks, add complexity to the process, making it time-consuming and conceptually challenging to retrieve accurate query results from blockchain data. |
10 | 30 |
|
11 |
| -المشاريع ذات العقود الذكية المعقدة مثل [ Uniswap ](https://uniswap.org/) و NFTs مثل [ Bored Ape Yacht Club ](https://boredapeyachtclub.com/) تقوم بتخزين البيانات على Ethereum blockchain ، مما يجعل من الصعب قراءة أي شيء بشكل مباشر عدا البيانات الأساسية من blockchain. |
| 31 | +## The Graph Provides a Solution |
12 | 32 |
|
13 |
| -In the case of Bored Ape Yacht Club, we can perform basic read operations on [the contract](https://etherscan.io/address/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d#code) like getting the owner of a certain Ape, getting the content URI of an Ape based on their ID, or the total supply. This can be done because these read operations are programmed directly into the smart contract. However, more advanced real-world queries and operations like aggregation, search, relationships, and non-trivial filtering are _not_ possible. For example, if we wanted to query for Apes that are owned by a certain address and filter by one of its characteristics, we would not be able to get that information by interacting directly with the contract itself. |
| 33 | +The Graph solves this challenge with a decentralized protocol that indexes and enables the efficient and high-performance querying of blockchain data. These APIs (indexed "subgraphs") can then be queried with a standard GraphQL API. |
14 | 34 |
|
15 |
| -To get this data, you would have to process every single [`transfer`](https://etherscan.io/address/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d#code#L1746) event ever emitted, read the metadata from IPFS using the Token ID and IPFS hash, and then aggregate it. It would take **hours or even days** for a decentralized application (dapp) running in a browser to get an answer to these simple questions. |
| 35 | +Today, there is a decentralized protocol that is backed by the open source implementation of [Graph Node](https://github.com/graphprotocol/graph-node) that enables this process. |
16 | 36 |
|
17 |
| -You could also build out your own server, process the transactions there, save them to a database, and build an API endpoint on top of it all in order to query the data. However, this option is [resource intensive](/network/benefits/), needs maintenance, presents a single point of failure, and breaks important security properties required for decentralization. |
| 37 | +### How The Graph Functions |
18 | 38 |
|
19 |
| -**إن فهرسة بيانات الـ blockchain أمر صعب.** |
| 39 | +Indexing blockchain data is very difficult, but The Graph makes it easy. The Graph learns how to index Ethereum data by using subgraphs. Subgraphs are custom APIs built on blockchain data that extract data from a blockchain, processes it, and stores it so that it can be seamlessly queried via GraphQL. |
20 | 40 |
|
21 |
| -Blockchain properties like finality, chain reorganizations, or uncled blocks complicate this process further. They make it time consuming and conceptually hard to retrieve correct query results from blockchain data. |
| 41 | +#### Specifics |
22 | 42 |
|
23 |
| -The Graph provides a solution with a decentralized protocol that indexes and enables the efficient and high-performance querying of blockchain data. These APIs (indexed "subgraphs") can then be queried with a standard GraphQL API. Today, there is a hosted service as well as a decentralized protocol with the same capabilities. Both are backed by the open source implementation of [Graph Node](https://github.com/graphprotocol/graph-node). |
| 43 | +- The Graph uses subgraph descriptions, which are known as the subgraph manifest inside the subgraph. |
24 | 44 |
|
25 |
| -## كيف يعمل The Graph |
| 45 | +- The subgraph description outlines the smart contracts of interest for a subgraph, the events within those contracts to focus on, and how to map event data to the data that The Graph will store in its database. |
26 | 46 |
|
27 |
| -The Graph يفهرس بيانات الإيثيريوم بناء على أوصاف الـ subgraph ، والمعروفة باسم subgraph manifest. حيث أن وصف الـ subgraph يحدد العقود الذكية ذات الأهمية لـ subgraph ، ويحدد الأحداث في تلك العقود التي يجب الانتباه إليها ، وكيفية عمل map لبيانات الحدث إلى البيانات التي سيخزنها The Graph في قاعدة البيانات الخاصة به. |
| 47 | +- When creating a subgraph, you need to write a subgraph manifest. |
28 | 48 |
|
29 |
| -بمجرد كتابة `subgraph manifest` ، يمكنك استخدام Graph CLI لتخزين التعريف في IPFS وإخبار المفهرس ببدء فهرسة البيانات لذلك الـ subgraph. |
| 49 | +- After writing the `subgraph manifest`, you can use the Graph CLI to store the definition in IPFS and instruct an Indexer to start indexing data for that subgraph. |
30 | 50 |
|
31 |
| -This diagram gives more detail about the flow of data once a subgraph manifest has been deployed, dealing with Ethereum transactions: |
| 51 | +The diagram below provides more detailed information about the flow of data after a subgraph manifest has been deployed with Ethereum transactions. |
32 | 52 |
|
33 | 53 | 
|
34 | 54 |
|
35 | 55 | تدفق البيانات يتبع الخطوات التالية:
|
36 | 56 |
|
37 |
| -1. A dapp adds data to Ethereum through a transaction on a smart contract. |
38 |
| -2. العقد الذكي يصدر حدثا واحدا أو أكثر أثناء معالجة الإجراء. |
39 |
| -3. يقوم الـ Graph Node بمسح الـ Ethereum باستمرار بحثا عن الكتل الجديدة وبيانات الـ subgraph الخاص بك. |
40 |
| -4. يعثر الـ Graph Node على أحداث الـ Ethereum لـ subgraph الخاص بك في هذه الكتل ويقوم بتشغيل mapping handlers التي قدمتها. الـ mapping عبارة عن وحدة WASM والتي تقوم بإنشاء أو تحديث البيانات التي يخزنها Graph Node استجابة لأحداث الـ Ethereum. |
41 |
| -5. The dapp queries the Graph Node for data indexed from the blockchain, using the node's [GraphQL endpoint](https://graphql.org/learn/). The Graph Node in turn translates the GraphQL queries into queries for its underlying data store in order to fetch this data, making use of the store's indexing capabilities. The dapp displays this data in a rich UI for end-users, which they use to issue new transactions on Ethereum. The cycle repeats. |
| 57 | +1. A dapp adds data to Ethereum through a transaction on a smart contract. |
| 58 | +2. العقد الذكي يصدر حدثا واحدا أو أكثر أثناء معالجة الإجراء. |
| 59 | +3. يقوم الـ Graph Node بمسح الـ Ethereum باستمرار بحثا عن الكتل الجديدة وبيانات الـ subgraph الخاص بك. |
| 60 | +4. يعثر الـ Graph Node على أحداث الـ Ethereum لـ subgraph الخاص بك في هذه الكتل ويقوم بتشغيل mapping handlers التي قدمتها. الـ mapping عبارة عن وحدة WASM والتي تقوم بإنشاء أو تحديث البيانات التي يخزنها Graph Node استجابة لأحداث الـ Ethereum. |
| 61 | +5. The dapp queries the Graph Node for data indexed from the blockchain, using the node's [GraphQL endpoint](https://graphql.org/learn/). The Graph Node in turn translates the GraphQL queries into queries for its underlying data store in order to fetch this data, making use of the store's indexing capabilities. The dapp displays this data in a rich UI for end-users, which they use to issue new transactions on Ethereum. The cycle repeats. |
42 | 62 |
|
43 | 63 | ## الخطوات التالية
|
44 | 64 |
|
45 |
| -The following sections provide more detail on how to define subgraphs, how to deploy them, and how to query data from the indexes that Graph Node builds. |
| 65 | +The following sections provide a more in-depth look at subgraphs, their deployment and data querying. |
46 | 66 |
|
47 |
| -Before you start writing your own subgraph, you might want to have a look at [Graph Explorer](https://thegraph.com/explorer) and explore some of the subgraphs that have already been deployed. The page for each subgraph contains a playground that lets you query that subgraph's data with GraphQL. |
| 67 | +Before you write your own subgraph, it's recommended to explore [Graph Explorer](https://thegraph.com/explorer) and review some of the already deployed subgraphs. Each subgraph's page includes a GraphQL playground, allowing you to query its data. |
0 commit comments