PHP code example of t3n / graphql-apollofederation

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

    

t3n / graphql-apollofederation example snippets




declare(strict_types=1);

namespace Some\Vendor\Namespace\Resolver;

use t3n\GraphQL\ApolloFederation\Resolver\ServiceQueryTrait;
use t3n\GraphQL\ResolverInterface;

class QueryResolver implements ResolverInterface
{
    use ServiceQueryTrait;

    // [...]
}



declare(strict_types=1);

namespace Some\Vendor\Namespace\Resolver;

use t3n\GraphQL\ApolloFederation\Resolver\EntitiesQueryTrait;
use t3n\GraphQL\ResolverInterface;

class QueryResolver implements ResolverInterface
{
    use EntitiesQueryTrait;

    // [...]
}

    # Return the typename of your Entity
    public function __resolveType(): string;

    /**
     * This method actually has to resolve your object/array that represents your entity
     *
     * @param array $variables those variables are passed down via the representation array
     */
    public function __resolveEntity(array $variables);