Skip to content

Commit ecadcbb

Browse files
committed
chore: update document
1 parent 329fea4 commit ecadcbb

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

docs/explanation/what-url-should-use-to-fetch-data.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ WPGraphQL supports querying data using the `/graphql` endpoint in two primary wa
1515
```bash
1616
curl 'http://myexample.local/graphql?query={generalSettings{url}}'
1717
```
18-
**Note**: GET requests have inherent URL length limitations (typically 2,000-8,000 characters depending on the browser and server). Complex GraphQL queries can easily exceed these limits, making this method impractical for anything beyond basic queries.
18+
**Note**: GET requests have inherent URL length limitations (typically 2,000-8,000 characters depending on the browser and server). Complex GraphQL queries can easily exceed these limits, making this method impractical for anything beyond basic queries1.
19+
20+
Each property is provided as an HTTP query parameter, with values separated by an ampersand (&)1.
21+
22+
GraphQL requests with variables don't work in GET requests because they need to be parsed as JSON1.
23+
24+
Only query operations can be executed; mutation operations don't work with GET requests1.
1925

2026
* **POST Request**: This is the standard method for querying WPGraphQL. You send a POST request to the `/graphql` endpoint with your GraphQL query in the request body. It supports complex queries and is more secure.
2127

@@ -30,4 +36,8 @@ curl -X POST \
3036
| Method | Security | Complexity | Support | Use Case |
3137
|--------------------------|------------------------------------------|-----------------|------------|------------------------|
3238
| POST | More secure, hides query in request body | Complex queries | Production | complex data retrieval |
33-
| GET with Query Parameter | Less secure due to query exposure in URL | Simple queries | Testing | simple data retrieval |
39+
| GET with Query Parameter | Less secure due to query exposure in URL | Simple queries (no mutations) | Testing | simple data retrieval |
40+
41+
# Summary
42+
While both methods have their uses, POST requests are generally recommended for WPGraphQL due to their flexibility, security advantages, and ability to handle complex queries. However, GET requests can be useful for simple, cacheable queries or quick testing. Consider your specific use case, security requirements, and caching needs when choosing between the two methods.
43+

0 commit comments

Comments
 (0)