承接 wpjshop/graphql-client 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

wpjshop/graphql-client

最新稳定版本:v2.4.1

Composer 安装命令:

composer require wpjshop/graphql-client

包简介

GraphQL client for WPJ GraphQL API.

README 文档

README

Installation

composer require wpjshop/graphql-client

Documentation

GraphQL API documentation here

Instantiate a client

<?php
$client = new \WpjShop\GraphQL\Client('https://your-domain/admin/graphql', '<authentication-token>');

Using the GraphQL Client

Simple use:

<?php
// Returns product data by ID.
$result = $client->product->get(1);
// Returns products collection.
$result = $client->product->list();
// Returns an array with result status and created product.
$result = $client->product->create(['title' => 'New product']);
// Returns an array with result status and updated product.
$result = $client->product->update(1, ['price' => ['priceWithoutVat' => 100]]);

// Returns parameter data by ID.
$result = $client->parameter->get(1);
// ...

Usage with custom field selection:

<?php
// Returns an array with data defined by `setSelection` method
$result = $client->product
    ->setSelection(
        [
            'id',
            'variations' => [
                'id',
                'price' => [
                    'withVat',
                    'vat',
                    'currency' => [
                        'code',
                    ],
                ],
            ],
        ]
)->get(1);

GraphQL Client Reference

Each service has at least 4 basic methods:

<?php
$client->{service}->get(int $id); // gets item by ID
$client->{service}->list(int $offset = 0, int $limit = 100); // items collection
$client->{service}->create(array $data); // create new item
$client->{service}->update(int $id, array $data); // updates item by ID

Services may have additional methods that are specific to them. For example update of product parameter:

<?php
$client->product->updateParameter(int $productId, int $parameterId, array $values, bool $append = false);

You can build custom query using this library that is a part of this client.

<?php
$client->runQuery($query, bool $resultsAsArray = false, array $variables = []);
$client->runRawQuery(string $queryString, $resultsAsArray = false, array $variables = []);

统计信息

  • 总下载量: 11.82k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-02-24