-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new CacheStrategy & CacheMiddleware classes #3
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
93f469c
Add new CacheStrategy class
jblz 84aa0f8
customize our TTL header
jblz 683ab17
Implement our own CacheMiddleware class that supports POST requests a…
jblz 3470574
add logging on fetch & cache; add mechanism to bypass cache
jblz ac27360
do not cache graphql mutations
jblz 8ae5f3b
Add phpunit test cases to the HttpClientTest
jblz 6bd4714
Merge branch 'trunk' of github.com:Automattic/remote-data-blocks into…
jblz 32a1c9b
Use much smaller Graphql Parsing lib: infinityloop-dev/graphpinator-p…
jblz 917bde9
POC cache TTL injection
chriszarate 9aba65a
Add GraphQLMutationContext
chriszarate 838c205
Provide sensible defaults for most queries
chriszarate 0717874
Remove GraphQL request body inspection
chriszarate 4e3956e
Merge branch 'trunk' of github.com:Automattic/remote-data-blocks into…
jblz 1132feb
Merge branch 'trunk' of github.com:Automattic/remote-data-blocks into…
jblz d4616ae
fixup spacing
jblz 31e42ba
Merge branch 'trunk' of github.com:Automattic/remote-data-blocks into…
jblz 65db305
fix casing on Config dir
jblz ae0fe37
lint fixes and type annotations / enhancements
jblz 83c1439
more php lint fixes
jblz aaf6be2
fix type issue caused by linter
jblz 8aadec8
Merge branch 'trunk' of github.com:Automattic/remote-data-blocks into…
jblz 90932a4
Merge branch 'trunk' into add/guzzle-caching-strategy
mhsdef 6cb94c0
Merge remote-tracking branch 'origin/trunk' into add/guzzle-caching-s…
chriszarate cb1ef74
Fix psalm issue
chriszarate cb058da
Merge remote-tracking branch 'origin/trunk' into add/guzzle-caching-s…
chriszarate 917fc00
Merge branch 'trunk' into add/guzzle-caching-strategy
jblz 2c6d343
Merge branch 'trunk' of github.com:Automattic/remote-data-blocks into…
jblz d148a41
make get_cache_ttl return a nullable int
jblz 30b0e00
Merge branch 'add/guzzle-caching-strategy' of github.com:Automattic/r…
jblz 757c6d7
tweak the constant name
jblz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace RemoteDataBlocks\Config\QueryContext; | ||
|
||
defined( 'ABSPATH' ) || exit(); | ||
|
||
/** | ||
* Base class used to define a Remote Data Query. This class defines a | ||
* composable query that allows it to be composed with another query or a block. | ||
* | ||
* @psalm-api | ||
*/ | ||
abstract class GraphqlMutationContext extends HttpQueryContext { | ||
|
||
/** | ||
* Override this method to define a custom request method for this mutation. | ||
*/ | ||
public function get_request_method(): string { | ||
return 'POST'; | ||
} | ||
|
||
/** | ||
* Define this method to provide the GraphQL mutation document. | ||
* | ||
* @return string The GraphQL mutation document. | ||
*/ | ||
abstract public function get_mutation(): string; | ||
|
||
/** | ||
* Override this method to define the GraphQL mutation variables. | ||
* | ||
* @return array The GraphQL query variables. | ||
*/ | ||
public function get_mutation_variables( array $input_variables ): array { | ||
return $input_variables; | ||
} | ||
|
||
/** | ||
* Convert the mutation and variables into a GraphQL request body. | ||
*/ | ||
public function get_request_body( array $input_variables ): array { | ||
$variables = $this->get_mutation_variables( $input_variables ); | ||
|
||
return [ | ||
'query' => $this->get_mutation(), | ||
'variables' => empty( $variables ) ? null : $variables, | ||
]; | ||
} | ||
|
||
/** | ||
* GraphQL mutations are uncachable by default. | ||
*/ | ||
public function get_cache_ttl( array $input_variables ): int { | ||
return -1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace RemoteDataBlocks\HttpClient; | ||
|
||
class RdbCacheMiddleware extends \Kevinrob\GuzzleCache\CacheMiddleware { | ||
/** | ||
* @var array<string, bool> | ||
*/ | ||
// phpcs:ignore WordPress.NamingConventions.ValidVariableName.PropertyNotSnakeCase, SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint | ||
protected $httpMethods = [ | ||
'GET' => true, | ||
'POST' => true, | ||
]; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are needed to comply with the parent class' declaration