oli / graphql-utils
GraphQL Utilities
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-10-29 06:06:01 UTC
README
Utils for use with webonyx/graphql-php
Quick start
composer require oligus/graphql-utils
sdf
Type Registry
Scalars exposed as static methods of GraphQLUtils\TypeRegistry class:
<?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
Custom Types
UUID Type
TypeRegistry::uuid()
Validates and returns a UUID object of type ramsey/uuid
Date Type
TypeRegistry::date($format)
Validates and returns a DateTime
object according to format of your own choosing.
You can only initialize the date type with format once. Initializing the date with a spcific format e.g.TypeRegistry::date('d/m/Y')
will mean all subsequent requests will be in the same format.
Default format: Y-m-d
Date Time Type
Date time in ATOM
format, RFC3339.
Format: Y-m-d\TH:i:sP
Money Type
TypeRegistry::money()
Validates and returns instance of Money (moneyphp/money), a PHP implementation of the Money pattern.