承接 blok/graphql 相关项目开发

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

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

blok/graphql

最新稳定版本:1.1.2

Composer 安装命令:

composer require blok/graphql

包简介

A graphql query and client helper

关键字:

README 文档

README

Build Status Packagist Packagist Packagist

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-03-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固