cronqvist/graphql-client 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

cronqvist/graphql-client

Composer 安装命令:

composer require cronqvist/graphql-client

包简介

A GraphQL client for executing queries and mutations

README 文档

README

A simple PHP library to interact with GraphQL APIs.

Installation

Run the following command to install the package using composer:

composer require cronqvist/graphql-client

Usage

Create an instance of Jc\GraphQL\GraphQLClient:

$client = new GraphQLClient($url);
$client->setAuthToken('xxx');

// Define the query or queries
$query = <<<'QUERY'
    query GetUser($id: ID!) {
      user (id: $id) {
        id,
        name,
        email
      }
    }
QUERY;

// Fetch the result of the query or queries from the GraphQL endpoint
$response = $client->fetch($query, ['id' => 1]);

// Get all the data
$response->data();

// If you only send one query, you can get access to it directly:
$user = $response->firstData();

// You can also access the data directly (user) via the getter
$user = $response->user;


// Fetch can be used with three arguments where variables and headers are optional
$response = $client->fetch($query, $variables, $headers);

Error handling:

// Easiest is to use the 'throwFirstError' method to throw an exception if any GraphQL error was returned:
$response->throwFirstError();

// or...

// Check if any errors exist
if($response->hasErrors()) {
    
    // Dump all errors
    var_dump($response->errors());
    
    // Or dump only the first error
    var_dump($response->firstError();
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-06-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固