https://github.com/mathsgod/gql-scalar-date
https://github.com/mathsgod/gql-scalar-date
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/mathsgod/gql-scalar-date
- Owner: mathsgod
- License: mit
- Created: 2019-10-31T09:57:02.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-11T02:58:56.000Z (over 6 years ago)
- Last Synced: 2025-03-13T09:03:24.941Z (over 1 year ago)
- Language: PHP
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gql-scalar-email
```php
$gql = "
scalar Date
scalar DateTime
type Query{
testDate(d:Date):Date
testDateTime(dt:DateTime):DateTime
}
";
$typeConfigDecorator = function ($typeConfig) {
$name = $typeConfig['name'];
if ($name === 'Date') {
$email = new Scalar\Date();
$typeConfig["serialize"] = [$email, "serialize"];
$typeConfig["parseLiteral"] = [$email, "parseLiteral"];
}
if ($name === 'DateTime') {
$email = new Scalar\DateTime();
$typeConfig["serialize"] = [$email, "serialize"];
$typeConfig["parseLiteral"] = [$email, "parseLiteral"];
}
return $typeConfig;
};
$schema = BuildSchema::build($gql, $typeConfigDecorator);
```