worksome/graphlint
Composer 安装命令:
composer create-project worksome/graphlint
包简介
A static analysis tool for GraphQL
README 文档
README
A linting tool for GraphQL schemas.
This tool is meant for finding errors in your GraphQL schemas. It is not made for your Queries. The tool contains multiple inspections which can be added to the user's config file for checking for different things. The purpose of this tool is to implement the GraphQL Standard from Worksome.
Installation
The tool can be installed as a composer global dependency via
composer global require worksome/graphlint
or via Homebrew
brew tap worksome/tap brew install --formula worksome/tap/graphlint
Usage
The tool can be run via
graphlint path/to/schema.graphql
CI Usage with GitHub Actions
With GitHub Actions, we support using the cs2pr
tool to add inline annotations to your pull requests.
graphlint --format=checkstyle path/to/schema.graphql | cs2pr
Configuration
⚠️ Currently the package only supports running on compiled schema. It will later get support for running on original schemas also.
Create a file in the root called graphlint.php with the following configuration.
<?php declare(strict_types=1); use Worksome\Graphlint\Config\GraphlintConfig; use Worksome\Graphlint\Inspections\CamelCaseFieldDefinitionInspection; return GraphlintConfig::configure() ->withInspections([ CamelCaseFieldDefinitionInspection::class, ]);
To use the Worksome GraphQL standard:
<?php declare(strict_types=1); use Worksome\Graphlint\Config\GraphlintConfig; return GraphlintConfig::configure() ->withPreparedSets(standard: true);
The tool can have a configuration for schemas before compiling and after. Some libraries do not compile their schema, so for those only one of the tags should be used.
Ignoring problems
A problem can be suppressed by adding an ignore-next-line comment before it.
interface Account { # @graphlint-ignore-next-line id: ID }
In some cases, it is not possible to add a comment because the schema is auto generated. For those cases, the error can be ignored by adding the following in the configuration file.
use Worksome\Graphlint\Config\GraphlintConfig; return GraphlintConfig::configure() // ... ->ignoring([ 'TEST', 'AccountInput.name' // Dotted value for only applying on some fields ]);
Testing
This package ships with a docker configuration for running the tests. Assuming you have cloned the repository and have docker and docker-compose installed, you can run the tests by running
docker-compose run --rm composer install # Only needed the first time
docker-compose run --rm pest
worksome/graphlint 适用场景与选型建议
worksome/graphlint 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 193.7k 次下载、GitHub Stars 达 13, 最近一次更新时间为 2022 年 06 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 worksome/graphlint 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 worksome/graphlint 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 193.7k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 13
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-06-14