You are here

public function SchemaCacheTest::testCaching in GraphQL 8.3

Test basic schema caching.

File

tests/src/Kernel/Framework/SchemaCacheTest.php, line 17

Class

SchemaCacheTest
Test schema caching.

Namespace

Drupal\Tests\graphql\Kernel\Framework

Code

public function testCaching() {

  // Create a first field.
  $this
    ->mockField('foo', [
    'id' => 'foo',
    'name' => 'foo',
    'type' => 'String',
  ], 'foo');

  // Run introspect to populate the schema cache.
  $this
    ->introspect();

  // Add another field.
  $this
    ->mockField('bar', [
    'id' => 'bar',
    'name' => 'bar',
    'type' => 'String',
  ], 'bar');

  // Run introspect again, the new field should not appear immediately.
  $schema = $this
    ->introspect();
  $this
    ->assertArrayNotHasKey('bar', $schema['types']['Query']['fields'], 'Schema has not been cached.');
}