nuwave / nuwave/lighthouse

Enums collisions are not detected when validating schema with native enums

Open
#1,962 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

discussion
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

  1. install https://github.com/BenSampo/laravel-enum
  2. 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';
}   
  1. create a new graphql enum with the same name
enum MyEnum {
    DONE
}
  1. run php artisan lighthouse:validate-schema
  2. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.