PHP code example of simpod / graphql-request-factory

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

    

simpod / graphql-request-factory example snippets




declare(strict_types=1);

namespace YourNs;

use SimPod\GraphQLRequestFactory\GraphQLRequestFactory;

$requestFactory = new GraphQLRequestFactory(new RequestFactoryInterfaceImpl(), new StreamFactoryInterfaceImpl());

$request = $requestFactory->createRequest(
    'https://localhost/graphql',
    <<<'GRAPHQL'
query GetHuman($id: ID!) {
  human(id: $id) {
    name
    appearsIn
    starships {
      name
    }
  }
}
GRAPHQL,
    ['id' => 1]
);

$response = $client->send($request);

$response = $client->sendRequest($request);