-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Directives are part of the GraphQL specification, this PR adds the Directive type. Follow up PRs would be needed to fully utilise the spec.
- Loading branch information
1 parent
6b22696
commit d9d2f62
Showing
10 changed files
with
338 additions
and
10 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
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
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,43 @@ | ||
<?php | ||
/* @var object $scope */ | ||
/* @var \SilverStripe\GraphQL\Schema\Type\Directive $directive */ | ||
/* @var array $globals */ | ||
?> | ||
<?php $directive = $scope; ?> | ||
namespace <?=$globals['namespace']; ?>; | ||
|
||
use GraphQL\Type\Definition\Directive; | ||
|
||
// @type:<?=$directive->getName(); ?> | ||
|
||
class <?=$globals['obfuscator']->obfuscate($directive->getName()) ?> extends Directive | ||
{ | ||
public function __construct() | ||
{ | ||
parent::__construct([ | ||
'name' => '<?=$directive->getName() ?>', | ||
<?php if (!empty($directive->getDescription())) : ?> | ||
'description' => '<?=addslashes($directive->getDescription()); ?>', | ||
<?php endif; ?> | ||
|
||
'locations' => [ | ||
<?php foreach ($directive->getLocations() as $location) : ?> | ||
'<?=$location; ?>', | ||
<?php endforeach; ?> | ||
], // locations | ||
<?php if (!empty($directive->getArgs())) : ?> | ||
'args' => [ | ||
<?php foreach ($directive->getArgs() as $arg) : ?> | ||
[ | ||
'name' => '<?=$arg->getName(); ?>', | ||
'type' => <?=$arg->getEncodedType()->encode(); ?>, | ||
<?php if ($arg->getDefaultValue() !== null) : ?> | ||
'defaultValue' => <?=var_export($arg->getDefaultValue(), true); ?>, | ||
<?php endif; ?> | ||
], // arg | ||
<?php endforeach; ?> | ||
], // args | ||
<?php endif; ?> | ||
]); | ||
} | ||
} |
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
Oops, something went wrong.