arrowsphere/catalog-graphql-client
Composer 安装命令:
composer require arrowsphere/catalog-graphql-client
包简介
The official PHP client for ArrowSphere's Catalog GraphQL API
关键字:
README 文档
README
This package provides a PHP client for ArrowSphere's Catalog GraphQL API. It should be the only way to make calls to ArrowSphere's Catalog GraphQL API with PHP code.
To use this package, you need valid access to ArrowSphere, with a valid token from the ArrowSphere's authentication platform.
Installation
Install the latest version with
$ composer require arrowsphere/catalog-graphql-client
Basic usage
<?php use ArrowSphere\CatalogGraphQLClient\CatalogGraphQLClient; use ArrowSphere\CatalogGraphQLClient\Input\SearchBody; use ArrowSphere\CatalogGraphQLClient\Types\ArrowsphereIdentifier; use ArrowSphere\CatalogGraphQLClient\Types\Identifiers; use ArrowSphere\CatalogGraphQLClient\Types\Product; use ArrowSphere\CatalogGraphQLClient\Types\Program; use ArrowSphere\CatalogGraphQLClient\Types\VendorIdentifier; const URL = 'https://your-url-to-arrowsphere.example.com'; $token = 'my token'; // The logic to get the token is not implemented in this package $client = new CatalogGraphQLClient(URL, $token); // The filters are defined as a nested array // They allow you to limit the data you want to see $filters = [ Product::CLASSIFICATION => 'SaaS', Product::IDENTIFIERS => [ Identifiers::VENDOR => [ VendorIdentifier::SKU => '031C9E47-4802-4248-838E-778FB1D2CC05', ], ], Product::PROGRAM => [ Program::LEGACY_CODE => 'microsoft', ], ]; // The fields are also defined as a nested array // They allow you to limit the fields returned by the GraphQL API, to see only the necessary fields for your need $fields = [ Product::NAME, Product::IDENTIFIERS => [ Identifiers::ARROWSPHERE => [ ArrowsphereIdentifier::ORDERABLE_SKU, ], Identifiers::VENDOR => [ VendorIdentifier::SKU, ] ] ]; $searchBody = [ SearchBody::MARKETPLACE => 'US', SearchBody::FILTERS => $filters, ]; $result = $client->find($searchBody, $fields); $products = $result->getProducts(); if (count($products) === 1) { $product = $products[0]; echo sprintf( "Product SKU %s : name = %s, orderable SKU = %s", $product->getIdentifiers()->getVendor()->getSku(), $product->getName(), $product->getIdentifiers()->getArrowsphere()->getOrderableSku() ) . PHP_EOL; }
More information
This library returns a result based on the entities defined in the ArrowSphere\CatalogGraphQLClient\Types namespace.
The find method from the CatalogGraphQLClient class is a simplified method that calls the getProducts query from the API and returns as instance of PaginatedProducts which allows you to access to any field you requested in the original query.
Please note that each field is nullable, you need to request a field for it to be populated by the API.
There is also a generic call method in the CatalogGraphQLClient class that allows you to perform any query on the GraphQL API. This method doesn't provide any help, so it's a bit complicated to use "as is". The usage of the find method is recommended.
arrowsphere/catalog-graphql-client 适用场景与选型建议
arrowsphere/catalog-graphql-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 37.76k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2021 年 01 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「graphql」 「arrowsphere」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 arrowsphere/catalog-graphql-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 arrowsphere/catalog-graphql-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 arrowsphere/catalog-graphql-client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The official PHP client for ArrowSphere's public API
Logs management in CloudWatch
GraphQL authentication for your headless Craft CMS applications.
Authorize introspection documentarion for rebing/graphql-laravel
Sylius backend integration for Vue Storefront 2
A PSR-7 compatible library for making CRUD API endpoints
统计信息
- 总下载量: 37.76k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-01-18