-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from worksome/feat-ignore-description-on-base-t…
…ypes Add support for ignoring root type names
- Loading branch information
Showing
5 changed files
with
49 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Worksome\Graphlint\Utils; | ||
|
||
use GraphQL\Language\AST\NameNode; | ||
|
||
class RootTypeChecker | ||
{ | ||
public function __construct( | ||
private readonly NodeNameResolver $nameResolver, | ||
) { | ||
} | ||
|
||
public function isRootName(NameNode $nameNode): bool | ||
{ | ||
$name = $this->nameResolver->getName($nameNode); | ||
|
||
if ($name === null) { | ||
return false; | ||
} | ||
|
||
return RootTypeName::tryFrom($name) !== null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Worksome\Graphlint\Utils; | ||
|
||
enum RootTypeName: string | ||
{ | ||
case Query = 'Query'; | ||
case Mutation = "Mutation"; | ||
} |
2 changes: 2 additions & 0 deletions
2
...ources/Inspections/DescriptionRequiredInspectionTest/mutation_query_type.skip.graphql.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
type Query | ||
type Mutation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters