You are here

public function ValidatorTest::testGetOrphanedResolversDetectsOrphanedInputObjectFieldResolvers in GraphQL 8.4

@covers ::getOrphanedResolvers

File

tests/src/Kernel/ValidatorTest.php, line 182

Class

ValidatorTest
Tests that the GraphQL validator behaves correctly.

Namespace

Drupal\Tests\graphql\Kernel

Code

public function testGetOrphanedResolversDetectsOrphanedInputObjectFieldResolvers() : void {
  $schema = <<<GQL
      type Mutation {
        createFakeObject(input: FakeInput!): User
      }

      type User {
        name: String!
      }

      input FakeInput {
        message: String!
      }

GQL;
  $this
    ->setUpSchema($schema);
  $this
    ->mockResolver('FakeInput', 'removed_field', $this->builder
    ->fromValue('Test User'));
  $validator = new Validator($this->schemaPluginManager);
  $orphaned_resolvers = $validator
    ->getOrphanedResolvers($this->server);
  self::assertEquals([
    'FakeInput' => [
      'removed_field',
    ],
  ], $orphaned_resolvers);
}