From 54297dad03554dd0df1fbe643ca5d3f2b5bb9e57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20S=C3=B8gaard?= Date: Thu, 3 Mar 2022 11:59:11 +0100 Subject: [PATCH 1/5] Add changeable root types --- src/Console/MutationCommand.php | 10 +++- src/Console/QueryCommand.php | 10 +++- src/Console/SubscriptionCommand.php | 10 +++- src/Defer/DeferrableDirective.php | 2 +- src/Federation/ASTManipulator.php | 6 +-- src/Federation/FederationPrinter.php | 8 +-- src/GlobalId/GlobalIdServiceProvider.php | 2 +- src/Schema/Factories/FieldFactory.php | 2 +- src/Schema/RootType.php | 50 ++++++++++++------- src/Schema/SchemaBuilder.php | 10 ++-- src/Schema/Values/TypeValue.php | 2 +- src/lighthouse.php | 14 ++++++ tests/Integration/IntrospectionTest.php | 2 +- .../Arguments/ArgumentSetFactoryTest.php | 2 +- tests/Unit/GlobalId/GlobalIdDirectiveTest.php | 2 +- tests/Unit/Schema/AST/ASTBuilderTest.php | 8 +-- tests/Unit/Schema/AST/DocumentASTTest.php | 6 +-- tests/Unit/Schema/ResolverProviderTest.php | 6 ++- tests/Unit/Schema/SchemaBuilderTest.php | 6 +-- 19 files changed, 108 insertions(+), 50 deletions(-) diff --git a/src/Console/MutationCommand.php b/src/Console/MutationCommand.php index 32ab865125..8179b47d1f 100644 --- a/src/Console/MutationCommand.php +++ b/src/Console/MutationCommand.php @@ -2,6 +2,7 @@ namespace Nuwave\Lighthouse\Console; +use Illuminate\Filesystem\Filesystem; use Nuwave\Lighthouse\Schema\RootType; class MutationCommand extends FieldGeneratorCommand @@ -10,7 +11,14 @@ class MutationCommand extends FieldGeneratorCommand protected $description = 'Create a class for a single field on the root Mutation type.'; - protected $type = RootType::MUTATION; + protected $type; + + public function __construct(Filesystem $files) + { + $this->type = RootType::Mutation(); + + parent::__construct($files); + } protected function namespaceConfigKey(): string { diff --git a/src/Console/QueryCommand.php b/src/Console/QueryCommand.php index 2a6932e3e3..f9316fcaf3 100644 --- a/src/Console/QueryCommand.php +++ b/src/Console/QueryCommand.php @@ -2,6 +2,7 @@ namespace Nuwave\Lighthouse\Console; +use Illuminate\Filesystem\Filesystem; use Nuwave\Lighthouse\Schema\RootType; class QueryCommand extends FieldGeneratorCommand @@ -10,7 +11,14 @@ class QueryCommand extends FieldGeneratorCommand protected $description = 'Create a class for a single field on the root Query type.'; - protected $type = RootType::QUERY; + protected $type; + + public function __construct(Filesystem $files) + { + $this->type = RootType::Query(); + + parent::__construct($files); + } protected function namespaceConfigKey(): string { diff --git a/src/Console/SubscriptionCommand.php b/src/Console/SubscriptionCommand.php index 873d529d3b..37b123233e 100644 --- a/src/Console/SubscriptionCommand.php +++ b/src/Console/SubscriptionCommand.php @@ -2,6 +2,7 @@ namespace Nuwave\Lighthouse\Console; +use Illuminate\Filesystem\Filesystem; use Nuwave\Lighthouse\Schema\RootType; class SubscriptionCommand extends LighthouseGeneratorCommand @@ -10,7 +11,14 @@ class SubscriptionCommand extends LighthouseGeneratorCommand protected $description = 'Create a class for a single field on the root Subscription type.'; - protected $type = RootType::SUBSCRIPTION; + protected $type; + + public function __construct(Filesystem $files) + { + $this->type = RootType::Subscription(); + + parent::__construct($files); + } protected function namespaceConfigKey(): string { diff --git a/src/Defer/DeferrableDirective.php b/src/Defer/DeferrableDirective.php index c59728dfa7..1a1215eca0 100644 --- a/src/Defer/DeferrableDirective.php +++ b/src/Defer/DeferrableDirective.php @@ -75,7 +75,7 @@ protected function shouldDefer(TypeNode $fieldType, ResolveInfo $resolveInfo): b $defers = (new ClientDirective(self::DEFER_DIRECTIVE_NAME))->forField($resolveInfo); if ($this->anyFieldHasDefer($defers)) { - if (RootType::MUTATION === $resolveInfo->parentType->name) { + if (RootType::Mutation() === $resolveInfo->parentType->name) { throw new Error(self::THE_DEFER_DIRECTIVE_CANNOT_BE_USED_ON_A_ROOT_MUTATION_FIELD); } if ($fieldType instanceof NonNullTypeNode) { diff --git a/src/Federation/ASTManipulator.php b/src/Federation/ASTManipulator.php index 78f93cd4b1..47c7229f57 100644 --- a/src/Federation/ASTManipulator.php +++ b/src/Federation/ASTManipulator.php @@ -76,12 +76,12 @@ protected function addRootFields(DocumentAST &$documentAST): void { // In federation it is fine for a schema to not have a user-defined root query type, // since we add two federation related fields to it here. - if (! isset($documentAST->types[RootType::QUERY])) { - $documentAST->types[RootType::QUERY] = Parser::objectTypeDefinition(/** @lang GraphQL */ 'type Query'); + if (! isset($documentAST->types[RootType::Query()])) { + $documentAST->types[RootType::Query()] = Parser::objectTypeDefinition(/** @lang GraphQL */ 'type Query'); } /** @var \GraphQL\Language\AST\ObjectTypeDefinitionNode $queryType */ - $queryType = $documentAST->types[RootType::QUERY]; + $queryType = $documentAST->types[RootType::Query()]; $queryType->fields[] = Parser::fieldDefinition(/** @lang GraphQL */ ' _entities( diff --git a/src/Federation/FederationPrinter.php b/src/Federation/FederationPrinter.php index e11fb57787..c376f99641 100644 --- a/src/Federation/FederationPrinter.php +++ b/src/Federation/FederationPrinter.php @@ -55,7 +55,7 @@ public static function print(Schema $schema): string } /** @var \GraphQL\Type\Definition\ObjectType $originalQueryType */ - $originalQueryType = Arr::pull($types, RootType::QUERY); + $originalQueryType = Arr::pull($types, RootType::Query()); $queryFieldsWithoutFederation = array_filter( $originalQueryType->getFields(), static function (FieldDefinition $field): bool { @@ -64,16 +64,16 @@ static function (FieldDefinition $field): bool { ); $newQueryType = count($queryFieldsWithoutFederation) > 0 ? new ObjectType([ - 'name' => RootType::QUERY, + 'name' => RootType::Query(), 'fields' => $queryFieldsWithoutFederation, 'interfaces' => $originalQueryType->getInterfaces(), ]) : null; $config->setQuery($newQueryType); - $config->setMutation(Arr::pull($types, RootType::MUTATION)); + $config->setMutation(Arr::pull($types, RootType::Mutation())); - $config->setSubscription(Arr::pull($types, RootType::SUBSCRIPTION)); + $config->setSubscription(Arr::pull($types, RootType::Subscription())); $config->setTypes($types); diff --git a/src/GlobalId/GlobalIdServiceProvider.php b/src/GlobalId/GlobalIdServiceProvider.php index 76a9215194..9e42373e56 100644 --- a/src/GlobalId/GlobalIdServiceProvider.php +++ b/src/GlobalId/GlobalIdServiceProvider.php @@ -65,7 +65,7 @@ interface $node @interface(resolveType: "Nuwave\\\Lighthouse\\\GlobalId\\\NodeRe ); /** @var \GraphQL\Language\AST\ObjectTypeDefinitionNode $queryType */ - $queryType = $documentAST->types[RootType::QUERY]; + $queryType = $documentAST->types[RootType::Query()]; $queryType->fields[] = Parser::fieldDefinition(/** @lang GraphQL */ <<<'GRAPHQL' node(id: ID! @globalId): Node @field(resolver: "Nuwave\\Lighthouse\\GlobalId\\NodeRegistry@resolve") GRAPHQL diff --git a/src/Schema/Factories/FieldFactory.php b/src/Schema/Factories/FieldFactory.php index ed5538e5dd..1c30b602fd 100644 --- a/src/Schema/Factories/FieldFactory.php +++ b/src/Schema/Factories/FieldFactory.php @@ -146,7 +146,7 @@ protected function complexity(FieldValue $fieldValue): ?callable public static function defaultResolver(FieldValue $fieldValue): callable { - if (RootType::SUBSCRIPTION === $fieldValue->getParentName()) { + if (RootType::Subscription() === $fieldValue->getParentName()) { /** @var \Nuwave\Lighthouse\Support\Contracts\ProvidesSubscriptionResolver $providesSubscriptionResolver */ $providesSubscriptionResolver = app(ProvidesSubscriptionResolver::class); diff --git a/src/Schema/RootType.php b/src/Schema/RootType.php index 8f00a616c6..a1c5b04aac 100644 --- a/src/Schema/RootType.php +++ b/src/Schema/RootType.php @@ -2,22 +2,43 @@ namespace Nuwave\Lighthouse\Schema; +use Illuminate\Support\Str; + class RootType { public const QUERY = 'Query'; public const MUTATION = 'Mutation'; public const SUBSCRIPTION = 'Subscription'; + public const NATIVE_TYPES = [ + 'Query', + 'Mutation', + 'Subscription', + ]; + + public static function Query(): string + { + return self::getType('Query'); + } + + public static function Mutation(): string + { + return self::getType('Mutation'); + } + + public static function Subscription(): string + { + return self::getType('Subscription'); + } + + private static function getType(string $nativeName): string + { + return config(sprintf('lighthouse.root_types.%s', Str::lower($nativeName))); + } + public static function isRootType(string $typeName): bool { - return in_array( - $typeName, - [ - static::QUERY, - static::MUTATION, - static::SUBSCRIPTION, - ] - ); + return in_array($typeName, static::NATIVE_TYPES); } /** @@ -25,15 +46,10 @@ public static function isRootType(string $typeName): bool */ public static function defaultNamespaces(string $typeName): array { - switch ($typeName) { - case static::QUERY: - return (array) config('lighthouse.namespaces.queries'); - case static::MUTATION: - return (array) config('lighthouse.namespaces.mutations'); - case static::SUBSCRIPTION: - return (array) config('lighthouse.namespaces.subscriptions'); - default: - return []; + if (!static::isRootType($typeName)) { + return []; } + + return (array) config(sprintf('lighthouse.namespaces.%s', Str::of($typeName)->plural()->lower())); } } diff --git a/src/Schema/SchemaBuilder.php b/src/Schema/SchemaBuilder.php index 6bae3f90ec..87e6b2789a 100644 --- a/src/Schema/SchemaBuilder.php +++ b/src/Schema/SchemaBuilder.php @@ -55,20 +55,20 @@ protected function build(DocumentAST $documentAST): Schema // Always set Query since it is required /** @var \GraphQL\Type\Definition\ObjectType $query */ - $query = $this->typeRegistry->get(RootType::QUERY); + $query = $this->typeRegistry->get(RootType::Query()); $config->setQuery($query); // Mutation and Subscription are optional, so only add them // if they are present in the schema - if (isset($documentAST->types[RootType::MUTATION])) { + if (isset($documentAST->types[RootType::Mutation()])) { /** @var \GraphQL\Type\Definition\ObjectType $mutation */ - $mutation = $this->typeRegistry->get(RootType::MUTATION); + $mutation = $this->typeRegistry->get(RootType::Mutation()); $config->setMutation($mutation); } - if (isset($documentAST->types[RootType::SUBSCRIPTION])) { + if (isset($documentAST->types[RootType::Subscription()])) { /** @var \GraphQL\Type\Definition\ObjectType $subscription */ - $subscription = $this->typeRegistry->get(RootType::SUBSCRIPTION); + $subscription = $this->typeRegistry->get(RootType::Subscription()); $config->setSubscription($subscription); } diff --git a/src/Schema/Values/TypeValue.php b/src/Schema/Values/TypeValue.php index dba0d7be4b..3d9f4a2769 100644 --- a/src/Schema/Values/TypeValue.php +++ b/src/Schema/Values/TypeValue.php @@ -54,7 +54,7 @@ public function cacheKey(): ?string $typeName = $this->getTypeDefinitionName(); // The Query type is exempt from requiring a cache key - if (RootType::QUERY === $typeName) { + if (RootType::Query() === $typeName) { return null; } diff --git a/src/lighthouse.php b/src/lighthouse.php index 64fde181e1..646d60f08c 100644 --- a/src/lighthouse.php +++ b/src/lighthouse.php @@ -497,6 +497,20 @@ 'max_execution_ms' => 0, ], + /* + |-------------------------------------------------------------------------- + | Root types + |-------------------------------------------------------------------------- + | + | Change root types to get around naming conflicts. + | + */ + 'root_types' => [ + 'query' => 'Query', + 'mutation' => 'Mutation', + 'subscription' => 'Subscription', + ], + /* |-------------------------------------------------------------------------- | Apollo Federation diff --git a/tests/Integration/IntrospectionTest.php b/tests/Integration/IntrospectionTest.php index 1b172a2494..48bea794b8 100644 --- a/tests/Integration/IntrospectionTest.php +++ b/tests/Integration/IntrospectionTest.php @@ -38,7 +38,7 @@ public function testFindsTypesFromSchema(): void $this->introspectType('Foo') ); $this->assertNotNull( - $this->introspectType(RootType::QUERY) + $this->introspectType(RootType::Query()) ); $this->assertNull( diff --git a/tests/Unit/Execution/Arguments/ArgumentSetFactoryTest.php b/tests/Unit/Execution/Arguments/ArgumentSetFactoryTest.php index 49451ae896..499bf43acd 100644 --- a/tests/Unit/Execution/Arguments/ArgumentSetFactoryTest.php +++ b/tests/Unit/Execution/Arguments/ArgumentSetFactoryTest.php @@ -184,7 +184,7 @@ protected function rootQueryArgumentSet(array $args): ArgumentSet $documentAST = $astBuilder->documentAST(); /** @var \GraphQL\Language\AST\ObjectTypeDefinitionNode $queryType */ - $queryType = $documentAST->types[RootType::QUERY]; + $queryType = $documentAST->types[RootType::Query()]; /** @var array<\GraphQL\Language\AST\FieldDefinitionNode> $fields */ $fields = $queryType->fields; diff --git a/tests/Unit/GlobalId/GlobalIdDirectiveTest.php b/tests/Unit/GlobalId/GlobalIdDirectiveTest.php index b0f055f020..b2f32dc0be 100644 --- a/tests/Unit/GlobalId/GlobalIdDirectiveTest.php +++ b/tests/Unit/GlobalId/GlobalIdDirectiveTest.php @@ -35,7 +35,7 @@ public function testDecodesGlobalId(): void } ')->assertJson([ 'data' => [ - 'foo' => $this->globalId->encode(RootType::QUERY, Foo::THE_ANSWER), + 'foo' => $this->globalId->encode(RootType::Query(), Foo::THE_ANSWER), ], ]); } diff --git a/tests/Unit/Schema/AST/ASTBuilderTest.php b/tests/Unit/Schema/AST/ASTBuilderTest.php index 76f4ec69af..96996ba43a 100644 --- a/tests/Unit/Schema/AST/ASTBuilderTest.php +++ b/tests/Unit/Schema/AST/ASTBuilderTest.php @@ -42,7 +42,7 @@ public function testMergeTypeExtensionFields(): void $documentAST = $this->astBuilder->documentAST(); /** @var \GraphQL\Language\AST\ObjectTypeDefinitionNode $queryType */ - $queryType = $documentAST->types[RootType::QUERY]; + $queryType = $documentAST->types[RootType::Query()]; $fields = $queryType->fields; $this->assertNotNull($fields); @@ -68,7 +68,7 @@ public function testAllowsExtendingUndefinedRootTypes(): void $documentAST = $this->astBuilder->documentAST(); /** @var \GraphQL\Language\AST\ObjectTypeDefinitionNode $queryType */ - $queryType = $documentAST->types[RootType::QUERY]; + $queryType = $documentAST->types[RootType::Query()]; $queryFields = $queryType->fields; $this->assertNotNull($queryFields); @@ -76,7 +76,7 @@ public function testAllowsExtendingUndefinedRootTypes(): void $this->assertCount(1, $queryFields); /** @var \GraphQL\Language\AST\ObjectTypeDefinitionNode $mutationType */ - $mutationType = $documentAST->types[RootType::MUTATION]; + $mutationType = $documentAST->types[RootType::Mutation()]; $mutationFields = $mutationType->fields; $this->assertNotNull($mutationFields); @@ -84,7 +84,7 @@ public function testAllowsExtendingUndefinedRootTypes(): void $this->assertCount(1, $mutationFields); /** @var \GraphQL\Language\AST\ObjectTypeDefinitionNode $subscriptionType */ - $subscriptionType = $documentAST->types[RootType::SUBSCRIPTION]; + $subscriptionType = $documentAST->types[RootType::Subscription()]; $subscriptionFields = $subscriptionType->fields; $this->assertNotNull($subscriptionFields); diff --git a/tests/Unit/Schema/AST/DocumentASTTest.php b/tests/Unit/Schema/AST/DocumentASTTest.php index 0bd933b3a2..9900094bc3 100644 --- a/tests/Unit/Schema/AST/DocumentASTTest.php +++ b/tests/Unit/Schema/AST/DocumentASTTest.php @@ -25,7 +25,7 @@ public function testParsesSimpleSchema(): void $this->assertInstanceOf( ObjectTypeDefinitionNode::class, - $documentAST->types[RootType::QUERY] + $documentAST->types[RootType::Query()] ); } @@ -79,7 +79,7 @@ public function testOverwritesDefinitionWithSameName(): void $this->assertSame( $overwrite, - $documentAST->types[RootType::QUERY] + $documentAST->types[RootType::Query()] ); } @@ -98,7 +98,7 @@ public function testBeSerialized(): void serialize($documentAST) ); - $queryType = $reserialized->types[RootType::QUERY]; + $queryType = $reserialized->types[RootType::Query()]; $this->assertInstanceOf(ObjectTypeDefinitionNode::class, $queryType); $this->assertInstanceOf(FieldDefinitionNode::class, $queryType->fields[0]); diff --git a/tests/Unit/Schema/ResolverProviderTest.php b/tests/Unit/Schema/ResolverProviderTest.php index 5ac92e68e7..286d7a2a74 100644 --- a/tests/Unit/Schema/ResolverProviderTest.php +++ b/tests/Unit/Schema/ResolverProviderTest.php @@ -64,8 +64,12 @@ public function testThrowsIfRootFieldHasNoResolver(): void ); } - protected function constructFieldValue(string $fieldDefinition, string $parentTypeName = RootType::QUERY): FieldValue + protected function constructFieldValue(string $fieldDefinition, string $parentTypeName = null): FieldValue { + if (is_null($parentTypeName)) { + $parentTypeName = RootType::Query(); + } + $queryType = Parser::objectTypeDefinition(/** @lang GraphQL */ " type {$parentTypeName} { {$fieldDefinition} diff --git a/tests/Unit/Schema/SchemaBuilderTest.php b/tests/Unit/Schema/SchemaBuilderTest.php index d67e40563e..2f94d4309f 100644 --- a/tests/Unit/Schema/SchemaBuilderTest.php +++ b/tests/Unit/Schema/SchemaBuilderTest.php @@ -52,7 +52,7 @@ public function testGeneratesWithEmptyMutationType(): void '); /** @var \GraphQL\Type\Definition\ObjectType $mutationObjectType */ - $mutationObjectType = $schema->getType(RootType::MUTATION); + $mutationObjectType = $schema->getType(RootType::Mutation()); $foo = $mutationObjectType->getField('foo'); $this->assertSame('foo', $foo->name); @@ -166,7 +166,7 @@ public function testResolveMutations(): void '); /** @var \GraphQL\Type\Definition\ObjectType $mutationObjectType */ - $mutationObjectType = $schema->getType(RootType::MUTATION); + $mutationObjectType = $schema->getType(RootType::Mutation()); $foo = $mutationObjectType->getField('foo'); $this->assertSame('foo', $foo->name); @@ -177,7 +177,7 @@ public function testResolveQueries(): void $schema = $this->buildSchemaWithPlaceholderQuery(); /** @var \GraphQL\Type\Definition\ObjectType $queryObjectType */ - $queryObjectType = $schema->getType(RootType::QUERY); + $queryObjectType = $schema->getType(RootType::Query()); $field = $queryObjectType->getField('foo'); $this->assertSame('foo', $field->name); From 152d25ea80569606f0b1ae9c1d0eb45a7aa79966 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20S=C3=B8gaard?= Date: Thu, 3 Mar 2022 20:40:27 +0100 Subject: [PATCH 2/5] Remove sprintf and Str::of --- src/Schema/RootType.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Schema/RootType.php b/src/Schema/RootType.php index a1c5b04aac..eaf35757d3 100644 --- a/src/Schema/RootType.php +++ b/src/Schema/RootType.php @@ -33,7 +33,7 @@ public static function Subscription(): string private static function getType(string $nativeName): string { - return config(sprintf('lighthouse.root_types.%s', Str::lower($nativeName))); + return config('lighthouse.root_types.' . Str::lower($nativeName)); } public static function isRootType(string $typeName): bool @@ -50,6 +50,6 @@ public static function defaultNamespaces(string $typeName): array return []; } - return (array) config(sprintf('lighthouse.namespaces.%s', Str::of($typeName)->plural()->lower())); + return (array) config('lighthouse.namespaces.' . Str::plural(Str::lower($typeName))); } } From 9c9941678a915c20e42e13c81357764cad360092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20S=C3=B8gaard?= Date: Thu, 3 Mar 2022 20:52:06 +0100 Subject: [PATCH 3/5] Revert changes --- src/Schema/RootType.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Schema/RootType.php b/src/Schema/RootType.php index eaf35757d3..d10796d9ea 100644 --- a/src/Schema/RootType.php +++ b/src/Schema/RootType.php @@ -38,7 +38,14 @@ private static function getType(string $nativeName): string public static function isRootType(string $typeName): bool { - return in_array($typeName, static::NATIVE_TYPES); + return in_array( + $typeName, + [ + static::QUERY, + static::MUTATION, + static::SUBSCRIPTION, + ] + ); } /** From c6501b24197cdf488c3edd3662e6a21639d01bd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20S=C3=B8gaard?= Date: Thu, 3 Mar 2022 20:52:23 +0100 Subject: [PATCH 4/5] Add fallback --- src/Schema/RootType.php | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Schema/RootType.php b/src/Schema/RootType.php index d10796d9ea..853b936734 100644 --- a/src/Schema/RootType.php +++ b/src/Schema/RootType.php @@ -10,30 +10,27 @@ class RootType public const MUTATION = 'Mutation'; public const SUBSCRIPTION = 'Subscription'; - public const NATIVE_TYPES = [ - 'Query', - 'Mutation', - 'Subscription', - ]; - public static function Query(): string { - return self::getType('Query'); + return self::getType(static::QUERY); } public static function Mutation(): string { - return self::getType('Mutation'); + return self::getType(static::MUTATION); } public static function Subscription(): string { - return self::getType('Subscription'); + return self::getType(static::SUBSCRIPTION); } private static function getType(string $nativeName): string { - return config('lighthouse.root_types.' . Str::lower($nativeName)); + return config( + 'lighthouse.root_types.' . Str::lower($nativeName), + $nativeName + ); } public static function isRootType(string $typeName): bool From 5703c60871ac08484b40a92a8a3b194a43067697 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20S=C3=B8gaard?= Date: Thu, 3 Mar 2022 20:52:45 +0100 Subject: [PATCH 5/5] Change param name for consistency --- src/Schema/RootType.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Schema/RootType.php b/src/Schema/RootType.php index 853b936734..5ca9f71811 100644 --- a/src/Schema/RootType.php +++ b/src/Schema/RootType.php @@ -25,11 +25,11 @@ public static function Subscription(): string return self::getType(static::SUBSCRIPTION); } - private static function getType(string $nativeName): string + private static function getType(string $typeName): string { return config( - 'lighthouse.root_types.' . Str::lower($nativeName), - $nativeName + 'lighthouse.root_types.' . Str::lower($typeName), + $typeName ); }