Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Graphql Php Scalars

Graphql Php Scalars Laravel Package

mll-lab/graphql-php-scalars

Custom scalar types for webonyx/graphql-php, including BigInt, Date/DateTime/DateTimeTz, Email, JSON, and IntRange for bounded integers. Drop-in types for schema definitions with strict parsing and DateTimeImmutable conversion for date scalars.

View on GitHub
Deep Wiki
Context7

A collection of custom scalar types for usage with https://github.com/webonyx/graphql-php

Frequently asked questions about Graphql Php Scalars
What is mll-lab/graphql-php-scalars used for in Laravel?
It provides custom scalar types for webonyx/graphql-php, the GraphQL library behind Laravel packages like Lighthouse. You use it to add strict types such as BigInt, Date, DateTime, Email, JSON and IntRange to your schema. It is a drop-in Composer package with minimal configuration.
How do I install mll-lab/graphql-php-scalars?
Install with composer require mll-lab/graphql-php-scalars. It is a library package, so there is no service provider or publish step required. After installation, reference the supplied scalar classes in your schema definitions or scalar registry.
Which custom GraphQL scalar types does the package provide?
The package includes BigInt, Date, DateTime, DateTimeTz, Email, JSON and IntRange. BigInt handles arbitrarily long integer digits, while Date, DateTime and DateTimeTz cover common date formats. IntRange is an abstract base for defining bounded integer scalars, and Email validates RFC 5321 compliant addresses.
How do I register mll-lab scalars in a Lighthouse schema?
In Lighthouse you typically register the scalar classes through your schema or a service provider using Lighthouse scalar registration mechanisms, such as ScalarTypeRegistry::register(...) where applicable. Then use the scalar names in your GraphQL SDL, for example field: DateTime. Follow your Lighthouse version documentation for custom scalar registration because the exact API can vary.
Does mll-lab/graphql-php-scalars work with Laravel Lighthouse?
Yes, it is designed for webonyx/graphql-php, which Lighthouse is built on. That makes the scalar classes usable in Lighthouse schemas once registered. You should verify compatibility between your Lighthouse, webonyx/graphql-php and PHP versions.
What Laravel, PHP and webonyx/graphql-php versions are supported?
The technical evaluation lists compatibility with webonyx/graphql-php v1.0+ and PHP 8.0+. Laravel support depends on your Laravel and Lighthouse versions because they determine the underlying webonyx/graphql-php constraint. Always run Composer dependency resolution against your application and test scalar behavior after upgrading.
How do the Date and DateTime scalars handle incoming and outgoing values?
Outgoing values can be valid date strings or DateTimeInterface instances. Incoming values must be valid date strings and are converted to DateTimeImmutable instances. Date expects Y-m-d, DateTime expects Y-m-d H:i:s, and DateTimeTz expects an ISO 8601 format such as 2020-04-20T16:20:04+04:00.
How do I create a bounded integer scalar with IntRange?
Extend MLL\GraphQLScalars\IntRange and implement the protected static min() and max() methods. For example, a class returning 1 from min() and 12 from max() defines an UpToADozen scalar. Then use that class as a scalar type in your schema and the package validates numeric values against the range.
How does the JSON scalar accept input values?
The JSON scalar expects a string containing valid JSON, not an arbitrary JSON value or GraphQL literal. In a schema field like foo(bar: JSON!): JSON!, pass a JSON-encoded string. This keeps parsing and serialization explicit and avoids ambiguity with GraphQL literals.
Is mll-lab/graphql-php-scalars production-ready and well maintained?
The package has a small code surface area, MIT licensing and automated validation plus code coverage badges in its repository. It relies on community GitHub issues rather than a formal SLA, so production use should include monitoring for webonyx/graphql-php updates. Test critical scalar validation and serialization paths in your own application, especially for Email, JSON and timezone-sensitive DateTime fields.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hsluv/hsluv
seampact/codegen
seampact/hooks
seampact/ir
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table
siberfx/flysystem-wasabi
hollyit/token-replace
ippanelcom/laravel-sdk
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support