Skip to content

Commit

Permalink
Merge pull request #6 from wp-graphql/feature/flush-loader-cache
Browse files Browse the repository at this point in the history
"clearLoaderCache" implemented.
  • Loading branch information
kidunot89 authored May 30, 2021
2 parents 9650e0c + f09b784 commit ce08b71
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
},
"require": {
"php": ">=7.1",
"phpunit/phpunit": "^7.5"
"phpunit/phpunit": "^7.5",
"wp-phpunit/wp-phpunit": "^5.7"
},
"require-dev": {
"composer/installers": "^1.9",
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ services:

mysql:
image: mysql
platform: linux/amd64
command: --default-authentication-plugin=mysql_native_password
environment:
MYSQL_ROOT_PASSWORD: password
Expand Down Expand Up @@ -33,6 +34,7 @@ services:

mysql_phpunit:
image: mysql:5.7
platform: linux/amd64
restart: always
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
Expand Down
16 changes: 15 additions & 1 deletion src/TestCase/WPGraphQLTestCommon.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,25 @@ public function graphql() {
*
* @return array
*/
public function clear_schema() {
public function clearSchema() {
// Clear schema
\WPGraphQL::clear_schema();
}

/**
* A simple helper for clearing a loaders cache. The is good for when
* running a query multiple times and wish to ensure that the value returned
* isn't a cached value.
*
* @param string $loader_name Loader slug name.
*
* @return void
*/
public function clearLoaderCache( $loader_name ) {
$loader = \WPGraphQL::get_app_context()->getLoader( $loader_name );
$loader->clearAll();
}

/**
* Wrapper for the "GraphQLRelay\Relay::toGlobalId()" function.
*
Expand Down

0 comments on commit ce08b71

Please sign in to comment.