andikaryanto11/ci4graphql

Codeigniter 4 的 ORM 数据库映射

v0.0.5 2021-08-06 04:12 UTC

This package is auto-updated.

Last update: 2024-09-08 20:29:09 UTC


README

此包创建用于在 ci4 中创建 graphql

安装

composer require andikaryanto11/ci4graphql

用法

  1. 创建控制器类,然后扩展到这个 AndikGraphql\Controller\GraphQL

  2. 在 ci4 路由文件中添加此行 AndikGraphql\Route\GraphqlRoute:routes($routes, 'YOUR_CONTROLLER::function')

  3. 在 app 目录下创建名为 'Graphql' 的目录(所有您的 graphql 工作都将在这里进行)。

  4. 解析器类必须扩展 AndikGraphql\LogicResolver,然后应该有一个名为 public function reveal({root}, {args}, {context}) 的函数

  5. 在 QueryResolver / MutationResolver 类中,您必须像这样注册您的突变 / 查询

       public function register()
       {
           $this->queries = [
               'getTest' => new Test(),
           ];
           return $this;
       }
    
  6. 查看示例目录,示例目录结构类似于 code igniter 4,以便更容易理解