承接 kevinoo/graphql-laravel-filters 相关项目开发

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

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

kevinoo/graphql-laravel-filters

最新稳定版本:1.0.0

Composer 安装命令:

composer require kevinoo/graphql-laravel-filters

包简介

This library extends the functionalities of rebing/graphql-laravel, providing a comprehensive solution for managing pagination and applying advanced filters to GraphQL queries in Laravel applications.

README 文档

README

This library extends the functionalities of "rebing/graphql-laravel," providing a comprehensive solution for managing pagination and applying advanced filters to GraphQL queries in Laravel applications.

Installation

Use Composer to install the library:

composer require kevinoo/graphql-laravel-filters

Usage

To utilize pagination in GraphQL queries, simply extend the AbstractPaginateQuery class provided by this library and use it in query resolvers.

use kevinoo\GraphQL\Queries;

class MyCustomModelQuery extends AbstractPaginateQuery 
{
//    public const GENERIC_FILTERS = true;
//    public const TRASHED_FILTER = true;
//    public const MAX_LIMIT_RESULTS = 1000;

    protected $attributes = [
        'name' => 'Name of Query',
    ];

    public function getGraphQLType(): string
    {
        return 'Your GraphQL Type';
    }

    public function args(): array
    {
        return parent::args() + [
            'filters' => [
                'type' => GraphQL::type('Your GraphQL FilterInput'),
            ],
        ];
    }

    protected function resolveModelBuilder( array $args ): Builder
    {
        $builder = YourModel::query();

        $order_by = ($args['orders'] ?? []) ?: ['domain'=>'ASC'];
        foreach( $order_by as $column => $direction ){
            $builder->orderBy($column,$direction);
        }

        return $builder;
    }

    protected function getGenericFiltersKeys(): array
    {
        return [
            'your_input_key_1' => 'model_attribute_1', // Input value can be string, int, boolean or array
            'your_input_key_2' => new AdvancedSearch('model_attribute_to_apply_advanced_search'),
            'your_input_key_3_array' => 'model_attribute_2',
        ];
    }

    protected function getPipelineFiltersSteps(): array
    {
        return parent::getPipelineFiltersSteps() + [
            // Add your other custom filters class
        ];
    }
}

Contributing

You are welcome to contribute to the project!

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-04-02