You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/src/pages/en/subgraphs/querying/graphql-api.mdx
+20-20Lines changed: 20 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ GraphQL queries in The Graph target entities defined in the Subgraph schema. Eac
30
30
31
31
> Note: The `query` keyword is not required at the top level of GraphQL queries.
32
32
33
-
### Single Entity Queries
33
+
### Single Entity Queries Example
34
34
35
35
Query for a single `Token` entity:
36
36
@@ -45,7 +45,7 @@ Query for a single `Token` entity:
45
45
46
46
> Note: Single entity queries require the `id` parameter as a string.
47
47
48
-
### Collection Queries
48
+
### Collection Queries Example
49
49
50
50
Query format for all `Token` entities:
51
51
@@ -58,14 +58,14 @@ Query format for all `Token` entities:
58
58
}
59
59
```
60
60
61
-
### Sorting
61
+
### Sorting Example
62
62
63
63
Collection queries support the following sort parameters:
64
64
65
65
-`orderBy`: Specifies the attribute for sorting
66
66
-`orderDirection`: Accepts `asc` (ascending) or `desc` (descending)
67
67
68
-
#### Standard Sorting
68
+
#### Standard Sorting Example
69
69
70
70
```graphql
71
71
{
@@ -76,7 +76,7 @@ Collection queries support the following sort parameters:
76
76
}
77
77
```
78
78
79
-
#### Nested Entity Sorting
79
+
#### Nested Entity Sorting Example
80
80
81
81
```graphql
82
82
{
@@ -91,7 +91,7 @@ Collection queries support the following sort parameters:
91
91
92
92
> Note: Nested sorting supports one-level-deep `String` or `ID` types on `@entity` and `@derivedFrom` fields.
93
93
94
-
### Pagination
94
+
### Pagination Example
95
95
96
96
When querying a collection, it is best to:
97
97
@@ -100,7 +100,7 @@ When querying a collection, it is best to:
100
100
- Use the `skip` parameter to skip entities and paginate. For instance, `first:100` shows the first 100 entities and `first:100, skip:100` shows the next 100 entities.
101
101
- Avoid using `skip` values in queries because they generally perform poorly. To retrieve a large number of items, it's best to page through entities based on an attribute as shown in the previous example above.
102
102
103
-
#### Standard Pagination
103
+
#### Standard Pagination Example
104
104
105
105
```graphql
106
106
{
@@ -111,7 +111,7 @@ When querying a collection, it is best to:
111
111
}
112
112
```
113
113
114
-
#### Offset Pagination
114
+
#### Offset Pagination Example
115
115
116
116
```graphql
117
117
{
@@ -122,7 +122,7 @@ When querying a collection, it is best to:
The `where` parameter filters entities based on specified conditions.
139
139
140
-
#### Basic Filtering
140
+
#### Basic Filtering Example
141
141
142
142
```graphql
143
143
{
@@ -151,7 +151,7 @@ The `where` parameter filters entities based on specified conditions.
151
151
}
152
152
```
153
153
154
-
#### Numeric Comparison
154
+
#### Numeric Comparison Example
155
155
156
156
```graphql
157
157
{
@@ -163,7 +163,7 @@ The `where` parameter filters entities based on specified conditions.
163
163
}
164
164
```
165
165
166
-
#### Block-based Filtering
166
+
#### Block-based Filtering Example
167
167
168
168
```graphql
169
169
{
@@ -175,7 +175,7 @@ The `where` parameter filters entities based on specified conditions.
175
175
}
176
176
```
177
177
178
-
#### Nested Entity Filtering
178
+
#### Nested Entity Filtering Example
179
179
180
180
```graphql
181
181
{
@@ -191,7 +191,7 @@ The `where` parameter filters entities based on specified conditions.
191
191
192
192
#### Logical Operators
193
193
194
-
##### AND Operations
194
+
##### AND Operations Example
195
195
196
196
The following example filters for challenges with `outcome``succeeded` and `number` greater than or equal to `100`.
197
197
@@ -221,7 +221,7 @@ The following example filters for challenges with `outcome` `succeeded` and `num
221
221
}
222
222
```
223
223
224
-
##### OR Operations
224
+
##### OR Operations Example
225
225
226
226
```graphql
227
227
{
@@ -241,7 +241,7 @@ Global filter parameter:
241
241
_change_block(number_gte: Int)
242
242
```
243
243
244
-
### Time-travel Queries
244
+
### Time-travel Queries Example
245
245
246
246
Queries support historical state retrieval using the `block` parameter:
247
247
@@ -250,7 +250,7 @@ Queries support historical state retrieval using the `block` parameter:
250
250
251
251
> Note: The current implementation is still subject to certain limitations that might violate these guarantees. The implementation can not always tell that a given block hash is not on the main chain at all, or if a query result by a block hash for a block that is not yet considered final could be influenced by a block reorganization running concurrently with the query. They do not affect the results of queries by block hash when the block is final and known to be on the main chain. [This issue](https://github.com/graphprotocol/graph-node/issues/1405) explains what these limitations are in detail.
252
252
253
-
#### Block Number Query
253
+
#### Block Number Query Example
254
254
255
255
```graphql
256
256
{
@@ -264,7 +264,7 @@ Queries support historical state retrieval using the `block` parameter:
264
264
}
265
265
```
266
266
267
-
#### Block Hash Query
267
+
#### Block Hash Query Example
268
268
269
269
```graphql
270
270
{
@@ -278,7 +278,7 @@ Queries support historical state retrieval using the `block` parameter:
278
278
}
279
279
```
280
280
281
-
### Full-Text Search
281
+
### Full-Text Search Example
282
282
283
283
Full-text search query fields provide an expressive text search API that can be added to the Subgraph schema and customized. Refer to [Defining Full-text Search Fields](/developing/creating-a-subgraph/#defining-fulltext-search-fields) to add full-text search to your Subgraph.
0 commit comments