Skip to content

Commit a39decb

Browse files
committed
Undefined scalar test.
1 parent 0a01356 commit a39decb

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/Unit/Schema/AST/ASTBuilderTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,26 @@ public function testMergeUnionExtensionFields(): void
322322
$this->assertCount(3, $myUnion->types);
323323
}
324324

325+
public function testDoesNotAllowExtendingUndefinedScalar(): void
326+
{
327+
$directive = new class() extends BaseDirective {
328+
public static function definition(): string
329+
{
330+
return /** @lang GraphQL */ 'directive @foo on SCALAR';
331+
}
332+
};
333+
334+
$directiveLocator = $this->app->make(DirectiveLocator::class);
335+
$directiveLocator->setResolved('foo', $directive::class);
336+
337+
$this->schema = /** @lang GraphQL */ '
338+
extend scalar MyScalar @foo
339+
';
340+
341+
$this->expectExceptionObject(new DefinitionException('Could not find a base definition MyScalar of kind ' . NodeKind::SCALAR_TYPE_EXTENSION . ' to extend.'));
342+
$this->astBuilder->documentAST();
343+
}
344+
325345
public function testDoesNotAllowExtendingUndefinedTypes(): void
326346
{
327347
$this->schema = /** @lang GraphQL */ '

0 commit comments

Comments
 (0)