oli / graphql-utils
GraphQL 工具集
0.1
2020-10-31 17:57 UTC
Requires
- ext-intl: *
- moneyphp/money: ^3.3
- oligus/schema: ^1.0@beta
- ramsey/uuid: ^4.0
- symfony/console: ^5.0
- webonyx/graphql-php: ^0.13.8
Requires (Dev)
- ext-json: *
- phan/phan: ^2.4
- phpmd/phpmd: ^2.8
- phpunit/phpunit: ^8.0
- spatie/phpunit-snapshot-assertions: 3.0
- squizlabs/php_codesniffer: ^3.5
- symfony/var-dumper: ^5.0
This package is auto-updated.
Last update: 2024-09-29 05:48:59 UTC
README
与webonyx/graphql-php一起使用的工具
快速入门
composer require oligus/graphql-utils
sdf
类型注册表
作为 GraphQLUtils\TypeRegistry 类静态方法的标量
<?php use GraphQLUtils\TypeRegistry; // Built-in Scalar types (wrapped from graphql): TypeRegistry::string(); // String type TypeRegistry::int(); // Int type TypeRegistry::float(); // Float type TypeRegistry::boolean(); // Boolean type TypeRegistry::id(); // ID type // Custom Scalar types: TypeRegistry::uuid(); // UUID type TypeRegistry::date(); // Date type TypeRegistry::dateTime(); // DateTime (Atom) type
自定义类型
UUID 类型
TypeRegistry::uuid()
验证并返回一个类型为 ramsey/uuid 的 UUID 对象
日期类型
TypeRegistry::date($format)
根据您选择的格式验证并返回一个 DateTime
对象。您只能用格式初始化日期类型一次。使用特定格式初始化日期,例如 TypeRegistry::date('d/m/Y')
,意味着所有后续请求都将使用相同的格式。
默认格式:Y-m-d
日期时间类型
以 ATOM
格式,RFC3339 的日期时间
格式:Y-m-d\TH:i:sP
货币类型
TypeRegistry::money()
验证并返回 Money (moneyphp/money) 实例,这是 Money 模式的 PHP 实现