luminarix/laravel-shopify-graphql

GraphQL client for Shopify.

v3.0.0 2024-12-16 01:17 UTC

This package is auto-updated.

Last update: 2024-12-16 01:19:19 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This is a work in progress package to provide a GraphQL client for Shopify.

Installation

You can install the package via composer:

composer require luminarix/laravel-shopify-graphql

You can publish the config file with:

php artisan vendor:publish --tag="laravel-shopify-graphql-config"

Usage

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);

Testing

composer test

Changelog

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

Credits

License

The MIT License (MIT). Please see License File for more information.