diff --git a/src/Config/Parser/GraphQL/ASTConverter/DirectiveNode.php b/src/Config/Parser/GraphQL/ASTConverter/DirectiveNode.php index abf16e4a1..f16ec04bf 100644 --- a/src/Config/Parser/GraphQL/ASTConverter/DirectiveNode.php +++ b/src/Config/Parser/GraphQL/ASTConverter/DirectiveNode.php @@ -21,6 +21,10 @@ public static function toConfig(Node $node): array $config['deprecationReason'] = $reason; break; } + + if ('resolve' === $directiveDef->name->value) { + $config['resolve'] = $directiveDef->arguments[0]->value->value; + } } return $config; diff --git a/src/Config/Parser/GraphQL/ASTConverter/FieldsNode.php b/src/Config/Parser/GraphQL/ASTConverter/FieldsNode.php index ddfbecda3..f7f53dc56 100644 --- a/src/Config/Parser/GraphQL/ASTConverter/FieldsNode.php +++ b/src/Config/Parser/GraphQL/ASTConverter/FieldsNode.php @@ -29,6 +29,10 @@ public static function toConfig(Node $node, string $property = 'fields'): array $fieldConfig['deprecationReason'] = $directiveConfig['deprecationReason']; } + if (isset($directiveConfig['resolve'])) { + $fieldConfig['resolve'] = $directiveConfig['resolve']; + } + $config[$definition->name->value] = $fieldConfig; } } diff --git a/src/Config/Parser/GraphQLParser.php b/src/Config/Parser/GraphQLParser.php index 8b944ef43..f7c897e39 100644 --- a/src/Config/Parser/GraphQLParser.php +++ b/src/Config/Parser/GraphQLParser.php @@ -69,6 +69,8 @@ public static function parse(SplFileInfo $file, ContainerBuilder $container, arr } else { self::throwUnsupportedDefinitionNode($typeDef); } + } else if (isset($typeDef->kind) && $typeDef->kind == NodeKind::DIRECTIVE_DEFINITION && isset($typeDef->name) && $typeDef->name->value == 'resolve') { + // Allow a directive named resolve } else { self::throwUnsupportedDefinitionNode($typeDef); }