edstevo / laravel-shopify-graph
A package for connecting to the Shopify Graph API
Fund package maintenance!
EdStevo
Installs: 94
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/edstevo/laravel-shopify-graph
Requires
- php: ^8.4
- illuminate/contracts: ^11.0||^12.0
- spatie/laravel-data: ^4.19
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^10.0.0||^9.0.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
This package is auto-updated.
Last update: 2026-02-02 22:21:44 UTC
README
Using this for personal projects, but feel free to use it if you want. I'm open to suggestions and pull requests.
Installation
You can install the package via composer:
composer require edstevo/laravel-shopify-graph
You can publish the config file with:
php artisan vendor:publish --tag=shopify-graph-config
This is the contents of the published config file:
return [ 'enabled' => true, 'api_verson' => null, ];
Usage
Use LaravelShopifyGraph facade to post Shopify Graph API requests:
LaravelShopifyGraph::post( "your-shop.myshopify.com", "access_token", "query { shop { name } }", [] // optional laravelShopifyGraphs ) app(\EdStevo\LaravelShopifyGraph\Laravellaravel-shopify-graphConnection::class)->post( "your-shop.myshopify.com", "access_token", "query { shop { name } }", [] // optional laravelShopifyGraphs )
Use Graph Request Classes to post Shopify Graph API requests:
class CreateBlogArticleRequest extends LaravelShopifyGraphRequest
{
public function __construct(public BlogArticle $article)
{
//
}
public function query(): string
{
return '
mutation CreateArticle($article: ArticleCreateInput!) {
articleCreate(article: $article) {
article {
id
}
userErrors {
code
field
message
}
}
}
';
}
public function variables(): array
{
return [
'article' => ArticleCreateInput::from($this->article->toShopifyPayload())->toArray(),
];
}
public function handleResponse(array $data): void
{
return $data;
}
}
$blogArticle = BlogArticle::first();
$request = new CreateBlogArticleRequest($blogArticle);
$response = $request->post("your-shop.myshopify.com", "access_token");
Use Laravel Queues to queue Shopify Graph API requests: (recommended for mutations)
class CreateBlogArticleRequest extends LaravelShopifyGraphJob
{
public function __construct(public BlogArticle $article, public string $shopDomain, public string $accessToken)
{
//
}
public function getShopDomain(): string
{
return $this->shopDomain;
}
public function getAccessToken(): string
{
return $this->accessToken;
}
public function query(): string
{
return '
mutation CreateArticle($article: ArticleCreateInput!) {
articleCreate(article: $article) {
article {
id
}
userErrors {
code
field
message
}
}
}
';
}
public function variables(): array
{
return [
'article' => ArticleCreateInput::from($this->article->toShopifyPayload())->toArray(),
];
}
public function handleResponse(array $data): void
{
$this->article->shopify_id = $data['articleCreate']['article']['id'];
$this->article->save();
}
}
$blogArticle = BlogArticle::first();
CreateBlogArticleRequest::dispatchNow($blogArticle, "your-shop.myshopify.com", "access_token");
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
All contributions welcome within reason. I don't have a lot of time to maintain this package, so any help is appreciated.
Credits
License
The MIT License (MIT).