Skip to content

Commit 4f958dd

Browse files
author
Jessica Mauerhan
authored
fix: ensure default directives do not get replaced by custom directives (#27)
* fix: ensure default directives do not get replaced by custom directives * style: fix imports
1 parent f3e647e commit 4f958dd

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/FederatedSchema.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use GraphQL\Type\Schema;
88
use GraphQL\Type\Definition\CustomScalarType;
9+
use GraphQL\Type\Definition\Directive;
910
use GraphQL\Type\Definition\ObjectType;
1011
use GraphQL\Type\Definition\UnionType;
1112
use GraphQL\Type\Definition\Type;
@@ -63,7 +64,7 @@ class FederatedSchema extends Schema
6364
public function __construct($config)
6465
{
6566
$this->entityTypes = $this->extractEntityTypes($config);
66-
$this->entityDirectives = Directives::getDirectives();
67+
$this->entityDirectives = array_merge(Directives::getDirectives(), Directive::getInternalDirectives());
6768

6869
$config = array_merge($config, $this->getEntityDirectivesConfig($config), $this->getQueryTypeConfig($config));
6970

test/SchemaTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ public function testDirectives()
6262
$this->assertArrayHasKey('external', $directives);
6363
$this->assertArrayHasKey('provides', $directives);
6464
$this->assertArrayHasKey('requires', $directives);
65+
66+
// These are the default directives, which should not be replaced
67+
// https://www.apollographql.com/docs/apollo-server/schema/directives#default-directives
68+
$this->assertArrayHasKey('include', $directives);
69+
$this->assertArrayHasKey('skip', $directives);
70+
$this->assertArrayHasKey('deprecated', $directives);
6571
}
6672

6773
public function testServiceSdl()

0 commit comments

Comments
 (0)