PHP code example of raphaelcangucu / gql-client

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

    

raphaelcangucu / gql-client example snippets


GRAPHQL_ENDPOINT="https://api.spacex.land/graphql/"

GRAPHQL_CREDENTIALS="YOUR_CREDENTIALS"

GRAPHQL_AUTHENTICATION_HEADER="Authorization"

// Allowed: basic, bearer, custom
GRAPHQL_AUTHENTICATION="bearer"

use RaphaelCangucu\GqlClient\Facades\GraphQL;

return GraphQL::query('
    capsules {
        id
        original_launch
        status
        missions {
            name
            flight
        }
    }
')->get();
//->get('json'); //get response as json object

return GraphQL::mutation('
    insert_user(name: "David") {
        id
        name
        date_added
    }
')->get();
//->get('json');

return GraphQL::raw('
    mutation($name: String) {
        insert_user(name: $name) {
            id
            name
            date_added
        }
    }
')
->with(["name" => "David"])
->get();
//->get('json');

return GraphQL::raw('
    mutation($name: String) {
        insert_user(name: $name) {
            id
            name
            date_added
        }
    }
')
->withName("David")
->get();
//->get('json');

return GraphQL::endpoint("https://api.spacex.land/graphql/")
->query('
    capsules {
        id
        original_launch
        status
        missions {
            name
            flight
        }
    }
')->get();
//->get('json');

return GraphQL::query($query)
->header('name', 'value')
->withHeaders([
    'name' => 'value',
    'name' => 'value'
])->get();

return GraphQL::query($query)
->context([
    'ssl' => [
         "verify_peer" => false,
         "verify_peer_name" => false,
    ]
  ])->get();
bash
php artisan vendor:publish --provider="RaphaelCangucu\GqlClient\GraphqlClientServiceProvider" --tag="config"