PHP code example of mathsgod / gql-client

1. Go to this page and download the library: Download mathsgod/gql-client 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-client example snippets


$client = new GQL\Client($server_address);

$data = $client->query([
    "me" => [
        "first_name", 
        "last_name"
    ]
]);

$client = new GQL\Client($server_address);

$data = $client->query([
    "getUser" => [
        "__args"=>[
            "id"=>1
        ],
        "first_name", 
        "last_name",
        "findInvoice"=>[
            "__args"=>[
                "status"=>"pending"
            ],
            "invoice_no"
        ]
    ]
]);

$data = $client->mutation("updateUser",[
    "__args"=>["user_id"=>1,"first_name"=>"Raymond"]
]);


$data=$client->subscription("createUser",[
    "__args"=>["first_name"=>"raymond"]
]);


$client = new GQL\Client($server_address);

$client->auth=["username","password"];

$data = $client->query([
    "me" => [
        "first_name",
        "last_name"
    ]
]);

$client = new GQL\Client($server_address,["verify"=>false]);


$data = $client->query([
    "me" => [
        "first_name",
        "last_name"
    ]
]);


echo Builder::Query([
     "me" => [
        "first_name",
        "last_name"
    ]
]);

// query{ me {first_name last_name} }


echo Builder:Mutation("updateUser",[
    "__args"=>[
        "user_id"=>1,
        "first_name"=>"Raymond"
    ]
]);
// mutation{ updateUser(user_id:1, first_name:"Raymond") }


echo Builder:Mutation("createUser",["__args"=>["first_name"=>"Raymond"]]);
// subscription{ createUser(first_name:"Raymond") }