Enums collisions are not detected when validating schema with native enums
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
When using native enums, as showcased here https://lighthouse-php.com/master/the-basics/types.html#native-php-definition coupled with https://github.com/BenSampo/laravel-enum
Enum name collisions are not detected when running php artisan lighthouse:validate-schema
Expected behavior/Solution
Validating schema should detect enum name collisions when using native php enums
Steps to reproduce
- install https://github.com/BenSampo/laravel-enum
- create a new enum MyEnum.php
<?php
declare(strict_types=1);
namespace App\Enums;
use BenSampo\Enum\Enum;
class MyEnum extends Enum
{
public const DONE = 'DONE';
}
- create a new graphql enum with the same name
enum MyEnum {
DONE
}
- run
php artisan lighthouse:validate-schema - Output is
The defined schema is valid.
Output/Logs
Click to expand
# Add in log output/error messages here
Lighthouse Version
4.18.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
Reproduce the issue using the native enum example and the php artisan lighthouse:validate-schema command, then trace how native PHP enums and GraphQL enums are loaded during schema validation. Compare the native-enum path with collision detection for regular GraphQL enums. Done means the command reports a collision for the duplicated MyEnum name.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, laravel, php
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100