"Date" scalar serialization on subscription results in conversion to string, fails internal type validation test
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 3.5k
- Forks
- 468
- Avg merge
- 3h 9m
- Merged PRs (30d)
- 2
Description
Describe the bug
For queries and mutations, Lighthouse converts the Date scalar to the Carbon library for convenient back-end development. For a subscription, Dates are cast to string before being passed to the Subscription handler (ex. "authorize"method). "Date" scalars are converted to UTC format like so: 2020-11-02T00:00:00.000000Z. Subscriptions must store the attribute values in memory in order to be available for the "filter" and "resolve" methods.
When later recalled for the "filter" or "resolve" methods, they then fail the type validation test within webonyx\graphql-php which is expecting a Date. The long-form
Expected behavior/Solution
Type coercion to Carbon instance for use within the Subscription class, and proper storage in memory so that the validation test doesn't later fail.
Steps to reproduce
- Make a subscription with a "Date" argument.
- Join subscription - this can work if Date argument is handled as string type
- Broadcast on channel fails due to type validation error.
Lighthouse Version
4.17.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the subscription argument handling and the authorize, filter, and resolve entry points described in the report, then trace Date scalar values through subscription storage and broadcast. Reproduce the failure with a Date argument and verify that the subscription receives the expected Carbon value and that broadcast no longer triggers webonyx/graphql-php type validation errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, php
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100