PHP code example of luminarix / laravel-shopify-graphql

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

    

luminarix / laravel-shopify-graphql example snippets


use Luminarix\Shopify\GraphQLClient\Facades\GraphQLClient;
use Luminarix\Shopify\GraphQLClient\Authenticators\ShopifyApp;

$graphql = GraphQLClient::factory();

$authenticator = new ShopifyApp($shopDomain, $accessToken, $apiVersion);

$client = $graphql->create($authenticator)

// Query
$query = 'query {
  node(id: "gid://shopify/Order/148977776") {
    id
    ... on Order {
      name
    }
  }
}';

$response = $client->query($query);

// Mutation
$mutation = 'mutation orderMarkAsPaid($input: OrderMarkAsPaidInput!) {
  orderMarkAsPaid(input: $input) {
    order {
      # Order fields
    }
    userErrors {
      field
      message
    }
  }
}';

$variables = [
  'input' => [
    'id' => 'gid://shopify/<objectName>/10079785100',
  ],
];

$response = $client->mutation($mutation, $variables);
bash
php artisan vendor:publish --tag="laravel-shopify-graphql-config"