mathsgod/light-graphql 问题修复 & 功能扩展

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

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

mathsgod/light-graphql

最新稳定版本:1.2.1

Composer 安装命令:

composer require mathsgod/light-graphql

包简介

Simple graphql server

README 文档

README

Light GraphQL is a lightweight GraphQL server implementation designed for simplicity and ease of use. This project demonstrates how to set up a basic GraphQL server using PHP.

This library is built using several dependencies, including thecodingmachine/graphqlite, which provides annotations and tools for creating GraphQL APIs in PHP. Other key dependencies include:

  • league/container: A lightweight dependency injection container.
  • symfony/cache: A caching library for optimizing performance.

These libraries work together to provide a robust and flexible foundation for building GraphQL servers.

Installation

composer require mathsgod/light-graphql

Key Components

  • Schema Factory: The schema is dynamically created using the SchemaFactory provided by the Light\GraphQL\Server. It allows adding namespaces for controllers.

  • Controllers: The Controllers namespace is used to define resolvers for GraphQL queries.

  • GraphQL Execution: The Server::executeQuery method is used to execute the GraphQL query against the schema. In the provided example, the query $query is executed, and the result is converted to an array using toArray().

Usage Example

use Controllers\RootController;
use GraphQL\GraphQL;

require_once __DIR__ . '/vendor/autoload.php';

$server = new \Light\GraphQL\Server();
$server->getSchemaFactory()->addNamespace("Controllers");

print_R($sever->executeQuery($query)->toArray());

ServerRequestInterface handling

use Controllers\RootController;
use GraphQL\GraphQL;

$server = new \Light\GraphQL\Server();
$server->getSchemaFactory()->addNamespace("Controllers");

$response=$server->handle($request);

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-17