Skip to content

Commit

Permalink
Fix merge conflict: make updates equivalent to the commit 4f958dd
Browse files Browse the repository at this point in the history
  • Loading branch information
a-melnikov committed Aug 29, 2022
1 parent 408c3e1 commit 07a0f9e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/SchemaBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Apollo\Federation;

use GraphQL\Type\Definition\Directive;

class SchemaBuilder
{
/**
Expand All @@ -27,6 +29,9 @@ public function build(array $schemaConfig, array $builderConfig = []): Federated
protected function getEntityDirectivesConfig(array $schemaConfig, array $builderConfig): array
{
$directives = array_intersect_key(Directives::getDirectives(), array_flip($builderConfig['directives']));
if (array_intersect_key($directives, Directive::getInternalDirectives())) {
throw new \LogicException('Some Apollo directives override internals.');
}
$schemaConfig['directives'] = array_merge($schemaConfig['directives'] ?? [], $directives);

return $schemaConfig;
Expand Down
3 changes: 3 additions & 0 deletions test/StarWarsSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Apollo\Federation\SchemaBuilder;
use Apollo\Federation\Types\EntityObjectType;
use Apollo\Federation\Types\EntityRefObjectType;
use GraphQL\Type\Definition\Directive;
use GraphQL\Type\Definition\ObjectType;
use GraphQL\Type\Definition\Type;

Expand All @@ -21,6 +22,7 @@ public static function getEpisodesSchema(): FederatedSchema
{
if (!self::$episodesSchema) {
self::$episodesSchema = (new SchemaBuilder())->build([
'directives' => Directive::getInternalDirectives(),
'query' => self::getQueryType(),
], [
'directives' => DirectiveEnum::getAll(),
Expand All @@ -34,6 +36,7 @@ public static function getEpisodesSchemaCustomResolver(): FederatedSchema
{
if (!self::$overriddenEpisodesSchema) {
self::$overriddenEpisodesSchema = (new SchemaBuilder())->build([
'directives' => Directive::getInternalDirectives(),
'query' => self::getQueryType(),
'resolve' => function ($root, $args, $context, $info): array {
return array_map(static function (array $ref) use ($info) {
Expand Down

0 comments on commit 07a0f9e

Please sign in to comment.