worksome/graphlint 问题修复 & 功能扩展

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

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

worksome/graphlint

Composer 安装命令:

composer create-project worksome/graphlint

包简介

A static analysis tool for GraphQL

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Static Analysis Action Status Total Downloads

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 我们能提供哪些服务?
定制开发 / 二次开发

基于 worksome/graphlint 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 193.7k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 13
  • 点击次数: 16
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 13
  • Watchers: 11
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-06-14