Skip to content

Commit e3d4e89

Browse files
committed
chore: revert doc updates
1 parent 14c7fcd commit e3d4e89

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

docs/explanation/get-vs-post.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# GET vs POST in WPGraphQL
22

3-
When interacting with WPGraphQL, choosing the correct URL and method to fetch data is crucial. This explanation clarifies the difference between using a GET request with a query parameter and a POST request to the `/graphql` endpoint.
3+
When interacting with WPGraphQL, selecting the correct HTTP method to fetch data is crucial. This guide explains the differences between using a GET request with a query parameter versus a POST request to the /graphql endpoint.
44

55
## Context
66

7-
WPGraphQL is a GraphQL API for WordPress, allowing you to query data in a flexible and efficient manner. GraphQL itself is a query language for APIs that provides a unified endpoint for data retrieval. Historically, APIs have used REST endpoints, which require multiple requests to gather related data. GraphQL, on the other hand, allows you to fetch specific data with a single query. WPGraphQL integrates this capability into WordPress.
7+
WPGraphQL is a GraphQL API for WordPress, enabling flexible and efficient data queries. Unlike traditional REST APIs that require multiple endpoints, GraphQL allows querying specific data through a single endpoint.
88

99
# Details
1010

11-
WPGraphQL supports querying data using the `/graphql` endpoint in two primary ways:
11+
WPGraphQL supports querying data using [the endpoint](/docs/explanation/graphql-endpoints.md) in two primary ways:
1212

1313
* **GET Request with Query Parameter**: You can query WPGraphQL by appending your GraphQL query as a query parameter to the `/graphql` endpoint. This method is useful for simple queries or testing purposes.
1414

@@ -23,11 +23,13 @@ Each property is provided as an HTTP query parameter, with values separated by a
2323
GraphQL requests with variables can work in GET requests, but the variables parameter must be properly encoded as a JSON string:
2424

2525
```text
26-
https://graphql-cache.local/graphql?query=query($slug:ID!){post(id:$slug,idType:SLUG,asPreview:false){title,content}}&variables={%22slug%22:%22hello-world%22}
26+
http://myexample.local/graphql?query=query($slug:ID!){post(id:$slug,idType:SLUG){title,content}}&variables={%22slug%22:%22hello-world%22}
2727
```
2828

2929
Only query operations can be executed; mutation operations don't work with GET requests.
3030

31+
GET requests can be particularly beneficial when used with caching mechanisms like the [Smart Cache plugin](https://wordpress.org/plugins/wpgraphql-smart-cache/). Since GET queries are part of the URL, they can be easily cached, reducing server load and improving response times for frequently requested data. This makes them a good choice for read-only queries where performance and efficiency are priorities.
32+
3133
* **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.
3234

3335
```bash
@@ -44,5 +46,4 @@ curl -X POST \
4446
| GET with Query Parameter | URLs in GET requests are visible in browser history, logs, and referrer headers, but when using HTTPS, the query itself is encrypted in transit. | Simple queries (no mutations) | Testing | simple data retrieval |
4547

4648
# Summary
47-
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.
48-
49+
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 and is useful when paired with caching mechanisms like the Smart Cache plugin. Consider your specific use case, security requirements, and caching needs when choosing between the two methods.

0 commit comments

Comments
 (0)