Skip to content

Commit 3d5be67

Browse files
authored
Merge pull request #379 from Shopify/liz/update-content-type-header
Remove application/graphql as a content type header
2 parents 5e390f1 + 83c49bf commit 3d5be67

5 files changed

Lines changed: 7 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

88
## Unreleased
99

10+
- [#379](https://github.com/Shopify/shopify-api-php/pull/379) [Patch] Fix GraphQL `Content-Type` header to be `application/json`
11+
1012
## v5.7.0 - 2024-10-22
1113
- [#371](https://github.com/Shopify/shopify-api-php/pull/371) [Minor] Remove API version validation to allow more flexibility of API version. And add support for 2024-10 API version
1214
- [#370](https://github.com/Shopify/shopify-api-php/pull/370) [Patch] Fix params set to zero being removed from request payload

src/Clients/Graphql.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,7 @@ public function query(
6060
$extraHeaders[$accessTokenHeader] = $accessToken;
6161

6262
if (is_array($data)) {
63-
$dataType = Http::DATA_TYPE_JSON;
6463
$data = json_encode($data);
65-
} else {
66-
$dataType = Http::DATA_TYPE_GRAPHQL;
6764
}
6865

6966
return $this->client->post(
@@ -72,7 +69,6 @@ public function query(
7269
$extraHeaders,
7370
$query,
7471
$tries,
75-
$dataType,
7672
);
7773
}
7874

src/Clients/Http.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class Http
2020
public const METHOD_DELETE = 'DELETE';
2121

2222
public const DATA_TYPE_JSON = 'application/json';
23-
public const DATA_TYPE_GRAPHQL = 'application/graphql';
2423

2524
private const RETRIABLE_STATUS_CODES = [429, 500];
2625
private const DEPRECATION_ALERT_SECONDS = 3600;

tests/Clients/GraphqlTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function testCanQueryWithDataString()
101101
'POST',
102102
"Shopify Admin API Library for PHP v$this->version",
103103
[
104-
'Content-Type: application/graphql',
104+
'Content-Type: application/json',
105105
'Content-Length: ' . strlen($this->testQueryString),
106106
'X-Shopify-Access-Token: token'
107107
],
@@ -182,7 +182,7 @@ public function testCanQueryWithExtraHeaders()
182182
'POST',
183183
"Shopify Admin API Library for PHP v$this->version",
184184
[
185-
'Content-Type: application/graphql',
185+
'Content-Type: application/json',
186186
'Content-Length: ' . strlen($this->testQueryString),
187187
'Extra-Extra: hear_all_about_it',
188188
'X-Shopify-Access-Token: token'

tests/Clients/StorefrontTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function testCanMakeRequest()
3838
'POST',
3939
null,
4040
[
41-
'Content-Type: application/graphql',
41+
'Content-Type: application/json',
4242
'X-Shopify-Storefront-Access-Token: test_token',
4343
],
4444
$this->query,
@@ -65,7 +65,7 @@ public function testCanMakeRequestForPrivateApp()
6565
'POST',
6666
null,
6767
[
68-
'Content-Type: application/graphql',
68+
'Content-Type: application/json',
6969
'X-Shopify-Storefront-Access-Token: private_token',
7070
],
7171
$this->query,
@@ -91,7 +91,7 @@ public function testCanUseTokenForPrivateAppRequest()
9191
'POST',
9292
null,
9393
[
94-
'Content-Type: application/graphql',
94+
'Content-Type: application/json',
9595
'X-Shopify-Storefront-Access-Token: test_token',
9696
],
9797
$this->query,

0 commit comments

Comments
 (0)