Skip to content

Commit

Permalink
fix: ensure default directives do not get replaced by custom directiv…
Browse files Browse the repository at this point in the history
…es (#27)

* fix: ensure default directives do not get replaced by custom directives

* style: fix imports
  • Loading branch information
Jessica Mauerhan authored Aug 16, 2022
1 parent f3e647e commit 4f958dd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/FederatedSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use GraphQL\Type\Schema;
use GraphQL\Type\Definition\CustomScalarType;
use GraphQL\Type\Definition\Directive;
use GraphQL\Type\Definition\ObjectType;
use GraphQL\Type\Definition\UnionType;
use GraphQL\Type\Definition\Type;
Expand Down Expand Up @@ -63,7 +64,7 @@ class FederatedSchema extends Schema
public function __construct($config)
{
$this->entityTypes = $this->extractEntityTypes($config);
$this->entityDirectives = Directives::getDirectives();
$this->entityDirectives = array_merge(Directives::getDirectives(), Directive::getInternalDirectives());

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

Expand Down
6 changes: 6 additions & 0 deletions test/SchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ public function testDirectives()
$this->assertArrayHasKey('external', $directives);
$this->assertArrayHasKey('provides', $directives);
$this->assertArrayHasKey('requires', $directives);

// These are the default directives, which should not be replaced
// https://www.apollographql.com/docs/apollo-server/schema/directives#default-directives
$this->assertArrayHasKey('include', $directives);
$this->assertArrayHasKey('skip', $directives);
$this->assertArrayHasKey('deprecated', $directives);
}

public function testServiceSdl()
Expand Down

0 comments on commit 4f958dd

Please sign in to comment.