2
2
3
3
A collection of custom scalar types for usage with https://github.com/webonyx/graphql-php
4
4
5
- [ ![ Continuous Integration ] ( https://github.com/mll-lab/graphql-php-scalars/workflows/Continuous%20Integration /badge.svg )] ( https://github.com/mll-lab/graphql-php-scalars/actions )
5
+ [ ![ Validate ] ( https://github.com/mll-lab/graphql-php-scalars/workflows/Validate /badge.svg )] ( https://github.com/mll-lab/graphql-php-scalars/actions )
6
6
[ ![ codecov] ( https://codecov.io/gh/mll-lab/graphql-php-scalars/branch/master/graph/badge.svg )] ( https://codecov.io/gh/mll-lab/graphql-php-scalars )
7
7
8
8
[ ![ GitHub license] ( https://img.shields.io/github/license/mll-lab/graphql-php-scalars.svg )] ( https://github.com/mll-lab/graphql-php-scalars/blob/master/LICENSE )
@@ -11,7 +11,9 @@ A collection of custom scalar types for usage with https://github.com/webonyx/gr
11
11
12
12
## Installation
13
13
14
- composer require mll-lab/graphql-php-scalars
14
+ ``` sh
15
+ composer require mll-lab/graphql-php-scalars
16
+ ```
15
17
16
18
## Usage
17
19
@@ -43,6 +45,27 @@ A datetime string with format `Y-m-d\TH:i:s.uP`, e.g. `2020-04-20T16:20:04+04:00
43
45
44
46
A [ RFC 5321] ( https://tools.ietf.org/html/rfc5321 ) compliant email.
45
47
48
+ ### [ IntRange] ( src/IntRange.php )
49
+
50
+ Allows defining numeric scalars where the values must lie between a defined minimum and maximum.
51
+
52
+ ``` php
53
+ use MLL\GraphQLScalars\IntRange;
54
+
55
+ final class UpToADozen extends IntRange
56
+ {
57
+ protected static function min(): int
58
+ {
59
+ return 1;
60
+ }
61
+
62
+ protected static function max(): int
63
+ {
64
+ return 12;
65
+ }
66
+ }
67
+ ```
68
+
46
69
### [ JSON] ( src/JSON.php )
47
70
48
71
Arbitrary data encoded in JavaScript Object Notation. See https://www.json.org .
@@ -131,13 +154,11 @@ use MLL\GraphQLScalars\Regex;
131
154
// The name is implicitly set through the class name here
132
155
class HexValue extends Regex
133
156
{
134
- /**
135
- * The description that is used for schema introspection.
136
- */
137
- public ?string $description = <<<'DESCRIPTION'
138
- A hexadecimal color is specified with: `#RRGGBB`, where `RR` (red), `GG` (green) and `BB` (blue)
139
- are hexadecimal integers between `00` and `FF` specifying the intensity of the color.
140
- DESCRIPTION;
157
+ /** The description that is used for schema introspection. */
158
+ public ?string $description = /** @lang Markdown */<<<'MARKDOWN'
159
+ A hexadecimal color is specified with: `#RRGGBB`, where `RR` (red), `GG` (green) and `BB` (blue)
160
+ are hexadecimal integers between `00` and `FF` specifying the intensity of the color.
161
+ MARKDOWN;
141
162
142
163
public static function regex(): string
143
164
{
@@ -160,13 +181,11 @@ use MLL\GraphQLScalars\StringScalar;
160
181
$coolName = StringScalar::make(
161
182
'CoolName',
162
183
'A name that is most definitely cool.',
163
- static function (string $name): bool {
164
- return in_array($name, [
165
- 'Vladar',
166
- 'Benedikt',
167
- 'Christopher',
168
- ]);
169
- }
184
+ static fn (string $name): bool => in_array($name, [
185
+ 'Vladar',
186
+ 'Benedikt',
187
+ 'Christopher',
188
+ ]),
170
189
);
171
190
```
172
191
0 commit comments