infinityloop-dev/graphpinator-where-directives
Composer 安装命令:
composer require infinityloop-dev/graphpinator-where-directives
包简介
Executable directives to filter values in lists.
README 文档
README
⚡🌐⚡ Executable directives to filter values in lists.
Introduction
This package allows client to filter list values using directives. Filtration happens on server, the most common use case is to save bandwidth when client knows exactly which data it needs.
Installation
Install package using composer
composer require infinityloop-dev/graphpinator-where-directives
How to use
⚠️ These directives do NOT replace standard and optimal filtering provided by arguments and underlying technologies. These directives serve only as an addition to these.
⚠️ These directives are executable directives. Their usage is requested by client. Think twice before including this functionality on your server.
In order to enable where directives on your server, the only thing you need to do is to put selected directives to your Container. You may use all or only some.
ListWhereDirectivehas a special requirement oninfinityloop-dev/graphpinator-constraint-directives, which needs to be enabled first if you wish to use@listWhere.
This package contains following directives:
\Graphpinator\WhereDirectives\StringWhereDirective\Graphpinator\WhereDirectives\IntWhereDirective\Graphpinator\WhereDirectives\FloatWhereDirective\Graphpinator\WhereDirectives\BooleanWhereDirective\Graphpinator\WhereDirectives\ListWhereDirective
Directive options
Common options
All directives have three common arguments
field(String) - This optional argument allows filtering of nested structures. Represents path to navigate into filtered value.- For more information visit following section.
orNull(Boolean) - Whether to accept null as a value which satisfies condition (default false).not(Boolean) - Negate the result of value conditions (default false).
Specific options
@stringWhere- equals
- contains
- startsWith
- endsWith
@intWhere&@floatWhere- equals
- greaterThan
- lessThan
@booleanWhere- equals
@listWhere- minItems
- maxItems
Priority of operations
Priority can be described using following code snippet:
$conditionIsMet = $value === null ? $orNull : satisfiesSpecificConditions($value); $valueIsFilteredOut = $conditionIsMet === $not;
This effectively means that not argument has lowest priority and negates even the orNull argument.
Field argument
Let's say we have a list of BlogPost objects with some fields in it.
Then, to receive all blogposts, we could have a query like this.
{ blogposts { title content likeCount author { name } } }
What if client needs only popular blogpost, with more than 100 likes, and server provides no relevant filtering options?
{ blogposts @intWhere(field: "likeCount", greaterThan: 100) { title content likeCount author { name } } }
What if client needs only post from author named "Foo Bar" ?
{ blogposts @stringWhere(field: "author.name", equals: "Foo Bar") { title content likeCount author { name } } }
infinityloop-dev/graphpinator-where-directives 适用场景与选型建议
infinityloop-dev/graphpinator-where-directives 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.47k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2021 年 02 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 infinityloop-dev/graphpinator-where-directives 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 infinityloop-dev/graphpinator-where-directives 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2.47k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 4
- 依赖项目数: 1
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2021-02-09