Skip to content

Commit 7a356c7

Browse files
author
Tyler King
committed
Added removeMiddleware, middleware names, and prep for release
1 parent 5b53d08 commit 7a356c7

2 files changed

Lines changed: 32 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# CHANGELOG
22

3+
# 9.0.0
4+
5+
*Contains breaking changes*; Consult `UPGRADING.md`.
6+
7+
+ Library refactored and split up, no longer one file
8+
+ Auth header handling moved into Guzzle middleware
9+
+ API versioning handler moved into Guzzle middleware
10+
+ Rate limiting improved and now available for GraphQL
11+
+ Options moved into its own configuration class
12+
+ "Retry" ability now built-in via `guzzle_retry_middleware` which respects Shopify's 'X-Retry-After' header
13+
+ API responses are now mapped into a response class which can be accessed as an array or object
14+
+ Storage of how/where rate limits, request times, and others are now changable with the `StateStorage` interface, and a default in-memory storage class provided
15+
+ Both GraphQL and REST success and error returns have been normalized
16+
317
# 8.2.0
418

519
+ Added `bodyArray` to response object of rest and graph, this is the same as `body` except instead of a stdClass being returned, its an array.

src/Osiset/BasicShopifyAPI/BasicShopifyAPI.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,11 @@ public function __construct(
124124
// Create the stack and assign the middleware which attempts to fix redirects
125125
$this->stack = HandlerStack::create($this->getOptions()->getGuzzleHandler());
126126
$this
127-
->addMiddleware(new AuthRequest($this))
128-
->addMiddleware(new RateLimiting($this))
129-
->addMiddleware(new UpdateApiLimits($this))
130-
->addMiddleware(new UpdateRequestTime($this))
131-
->addMiddleware(GuzzleRetryMiddleware::factory());
127+
->addMiddleware(new AuthRequest($this), 'request:auth')
128+
->addMiddleware(new RateLimiting($this), 'rate:limiting')
129+
->addMiddleware(new UpdateApiLimits($this), 'rate:update')
130+
->addMiddleware(new UpdateRequestTime($this), 'time:update')
131+
->addMiddleware(GuzzleRetryMiddleware::factory(), 'request:retry');
132132

133133
// Create a default Guzzle client with our stack
134134
$this->setClient(
@@ -270,6 +270,19 @@ public function addMiddleware(callable $callable, string $name = ''): self
270270
return $this;
271271
}
272272

273+
/**
274+
* Remove middleware to the handler stack.
275+
*
276+
* @param string $name Name to register for this middleware.
277+
*
278+
* @return self
279+
*/
280+
public function removeMiddleware(string $name = ''): self
281+
{
282+
$this->stack->remove($name);
283+
return $this;
284+
}
285+
273286
/**
274287
* @see Rest::getAuthUrl
275288
*/

0 commit comments

Comments
 (0)