mathsgod/gql-scalar-email

graphql scalar email

1.0.3 2019-10-31 08:23 UTC

This package is auto-updated.

Last update: 2024-04-29 04:06:52 UTC


README

    
    $gql = "
scalar Email
type Query{
    test(email:Email):Email
}      
";

   $typeConfigDecorator = function ($typeConfig) {
        $name = $typeConfig['name'];

        if ($name === 'Email') {
            $email = new Scalar\Email();

            $typeConfig["serialize"] = [$email, "serialize"];
            $typeConfig["parseLiteral"] = [$email, "parseLiteral"];
        }
        return $typeConfig;
    };

    $schema = BuildSchema::build($gql, $typeConfigDecorator);