1. Go to this page and download the library: Download toppynl/graphql-federation 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/ */
toppynl / graphql-federation example snippets
use Toppynl\GraphQLFederation\FederatedSchemaBuilder;
$fedSchema = FederatedSchemaBuilder::from($schema)
->withReferenceResolver('Product', 'id', function (array $rep): array {
return ProductRepository::findById($rep['id']);
})
->build();
// $fedSchema->schema is a standard webonyx Schema — pass it to GraphQL::executeQuery() as normal
$result = GraphQL::executeQuery($fedSchema->schema, $query, rootValue: null, contextValue: $context);