mathsgod/gql-scalar-date

1.0.0 2019-11-01 02:41 UTC

This package is auto-updated.

Last update: 2024-12-11 15:54:18 UTC


README

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