An open API service indexing awesome lists of open source software.

https://github.com/mathsgod/gql-scalar-date


https://github.com/mathsgod/gql-scalar-date

Last synced: about 1 year ago
JSON representation

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);
```