Skip to content

mcarrowsmith/shopify-graphql-client

Repository files navigation

Shopify GraphQL Client

PHP Client to send GraphQL requests to Shopify Admin API.

Installation

You can install the package via composer:

composer require mcarrowsmith-packages/shopify-graphql-client

Usage

Make sure you have correct credentials to access the Shopify Store via Partner Account or Custom App.

use \McArrowsmithPackages\ShopifyGraphQLClient\ClientFactory;

$query = <<<'QUERY'
query {
  shop {
    name
  }
}
QUERY;

$factory = ClientFactory::make('example.myshopify.com', '<API-TOKEN>', '2022-07');

try {
    $factory->request($query);
} catch (\Throwable $t) {
    echo $t->getMessage() . PHP_EOL;
}

See scripts for full usage and examples.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.