PHP code example of compwright / graphql-php-jetpack

1. Go to this page and download the library: Download compwright/graphql-php-jetpack 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/ */

    

compwright / graphql-php-jetpack example snippets


use Compwright\GraphqlPhpJetpack\JetpackDecorator;
use GraphQL\Utils\BuildSchema;

$schemaTypeDecorator = new JetpackDecorator();
$schema = BuildSchema::build($ast, $schemaTypeDecorator);

use Compwright\GraphqlPhpJetpack\DirectiveResolver;
use GraphQL\Server\ServerConfig;
use GraphQL\Type\Definition\ResolveInfo;

$resolver = function ($root, array $args, $context, ResolveInfo $info) {
    // resolve field value
    return $root;
};

$serverConfig = ServerConfig::create()
    ->setFieldResolver(new DirectiveResolver($resolver));

$ composer