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/pages/en/querying/querying-best-practices.mdx
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,15 +2,15 @@
2
2
title: Querying Best Practices
3
3
---
4
4
5
-
The Graph provides a decentralized way to query data from blockchains via GraphQL APIs, making it easier to query data with the GraphQL language.
5
+
The Graph provides a decentralized way to query data from blockchains. Its data is exposed through a GraphQL API, making it easier to query with the GraphQL language.
6
6
7
-
Learn the essential GraphQL language rules and GraphQL querying best practices.
7
+
Learn the essential GraphQL language rules and best practices to optimize your subgraph.
8
8
9
9
---
10
10
11
11
## Querying a GraphQL API
12
12
13
-
### The anatomy of a GraphQL query
13
+
### The Anatomy of a GraphQL Query
14
14
15
15
Unlike REST API, a GraphQL API is built upon a Schema that defines which queries can be performed.
While the list of syntactic do's and don'ts is long, here are the essential rules to keep in mind when it comes to writing GraphQL queries:
53
+
## Rules for Writing GraphQL Queries
54
54
55
55
- Each `queryName` must only be used once per operation.
56
56
- Each `field` must be used only once in a selection (we cannot query `id` twice under `token`)
@@ -59,17 +59,17 @@ While the list of syntactic do's and don'ts is long, here are the essential rule
59
59
- In a given list of variables, each of them must be unique.
60
60
- All defined variables must be used.
61
61
62
-
Failing to follow the above rules will end with an error from the Graph API.
62
+
> Note: Failing to follow these rules will result in an error from The Graph API.
63
63
64
-
For a complete list of rules with code examples, please look at our[GraphQL Validations guide](/release-notes/graphql-validations-migration-guide/).
64
+
For a complete list of rules with code examples, check out[GraphQL Validations guide](/release-notes/graphql-validations-migration-guide/).
65
65
66
66
### Sending a query to a GraphQL API
67
67
68
68
GraphQL is a language and set of conventions that transport over HTTP.
69
69
70
70
It means that you can query a GraphQL API using standard `fetch` (natively or via `@whatwg-node/fetch` or `isomorphic-fetch`).
71
71
72
-
However, as stated in ["Querying from an Application"](/querying/querying-from-an-application), it's recommend to use `graph-client` which supports unique features such as:
72
+
However, as mentioned in ["Querying from an Application"](/querying/querying-from-an-application), it's recommended to use `graph-client`, which supports the following unique features:
73
73
74
74
- Cross-chain Subgraph Handling: Querying from multiple subgraphs in a single query
0 commit comments