1. Go to this page and download the library: Download mll-lab/graphql-php-scalars library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mll-lab / graphql-php-scalars example snippets
use MLL\GraphQLScalars\IntRange;
final class UpToADozen extends IntRange
{
protected static function min(): int
{
return 1;
}
protected static function max(): int
{
return 12;
}
}
use MLL\GraphQLScalars\Regex;
$hexValue = Regex::make(
'HexValue',
'A hexadecimal color is specified with: `#RRGGBB`, where `RR` (red), `GG` (green) and `BB` (blue) are hexadecimal integers between `00` and `FF` specifying the intensity of the color.',
'/^#?([a-f0-9]{6}|[a-f0-9]{3})$/'
);
use MLL\GraphQLScalars\Regex;
// The name is implicitly set through the class name here
class HexValue extends Regex
{
/** The description that is used for schema introspection. */
public ?string $description = /** @lang Markdown */<<<'MARKDOWN'
A hexadecimal color is specified with: `#RRGGBB`, where `RR` (red), `GG` (green) and `BB` (blue)
are hexadecimal integers between `00` and `FF` specifying the intensity of the color.
MARKDOWN;
public static function regex(): string
{
return '/^#?([a-f0-9]{6}|[a-f0-9]{3})$/';
}
}
use MLL\GraphQLScalars\StringScalar;
$coolName = StringScalar::make(
'CoolName',
'A name that is most definitely cool.',
static fn (string $name): bool => in_array($name, [
'Vladar',
'Benedikt',
'Christopher',
]),
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.