blok/graphql
最新稳定版本:1.1.2
Composer 安装命令:
composer require blok/graphql
包简介
A graphql query and client helper
关键字:
README 文档
README
Package description :
Very simple GraphqlClient helper to make a graphql call.
Installation
Install via composer
composer require blok/graphql
Register Service Provider
Note! This and next step are optional if you use laravel>=5.5 with package auto discovery feature.
Add service provider to config/app.php in providers section
Blok\Graphql\ServiceProvider::class,
Register Facade
Register package facade in config/app.php in aliases section
Blok\Graphql\Facades\Graphql::class,
Publish Configuration File
php artisan vendor:publish --provider="Blok\Graphql\ServiceProvider" --tag="config"
Usage as a standalone php
Simply add your query and param like that (here is an exemple with the Opencollective GraphQL api) :
use Blok\Graphql\Graphql;
$query = <<<EOT
query allTransactions(\$slug: String){
allTransactions(collectiveSlug: \$slug){
id,
uuid,
amount,
currency,
description,
hostCurrency,
hostCurrencyFxRate,
netAmountInCollectiveCurrency,
type,
createdAt,
updatedAt,
refundTransaction{id},
collective{id, name, slug},
}
}
EOT;
$graphql = new Graphql(YOUR_URL, YOUR_BEARER_TOKEN);
$result = $graphql->query($query, ['slug' => 'co-labs']);
Use as a Laravel Graphql instance
For convenience you have also an instanciated graphql service provider that will use the setup from your env file : GRAPHQL_URL and GRAPHQL_TOKEN.
To use it you can use the Facade or app :
use Blok\Graphql\Facades\Graphql;
$query = <<<EOT
query allTransactions(\$slug: String){
allTransactions(collectiveSlug: \$slug){
id,
uuid,
amount,
currency,
description,
hostCurrency,
hostCurrencyFxRate,
netAmountInCollectiveCurrency,
type,
createdAt,
updatedAt,
refundTransaction{id},
collective{id, name, slug},
}
}
EOT;
$result = app('graphql')->query($query, ['slug' => 'co-labs']);
or
$result = Graphql::query($query, ['slug' => 'co-labs']);
Security
If you discover any security related issues, please email instead of using the issue tracker.
Credits
This package is bootstrapped with the help of blok/laravel-package-generator.
统计信息
- 总下载量: 1.3k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-03-31