PHP code example of mathsgod / gql-scalar-email

1. Go to this page and download the library: Download mathsgod/gql-scalar-email library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mathsgod / gql-scalar-email example snippets


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