Allow GraphQL types named like PHP reserved keywords in federation entity resolver
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start by reading the federation entity-resolution flow around EntityResolverProvider and the configuration in config/lighthouse.php. Compare the proposed resolver naming and referenceResolvers mapping approaches, then define how a GraphQL type such as Class should resolve without requiring an invalid PHP class name. Done means reserved-keyword entity references resolve through a documented, tested approach.
Written by the indexing model from the issue text.
Description
What problem does this feature proposal attempt to solve?
At the moment it seems that lighthouse is not able to resolve entities reference for types that are reserved PHP words out of the box.
For instance we are using this type Class in our graph which we didn't have problem with at first, but now that we need EntityReference resolver this is a problem because lighthouse is looking for a class with the same __typename which is not possible in PHP class Class {}.
Which possible solutions should be considered?
Option 1.
Entity reference resolver could be suffixed by Resolver or ReferenceResolver to allow fo this to work.
namespace App\GraphQL\ReferenceResolvers;
use Nuwave\Lighthouse\Federation\BatchedEntityResolver;
final class ClassResolver implements BatchedEntityResolver
{
...
}
Option 2.
Another solution would be to provide a mapping in the lighthouse configuration
// config/lighthouse.php
return [
'referenceResolvers' => [
// '__typename' => 'FQN',
'class' => 'App\GraphQL\ReferenceResolvers\ClassResolver',
],
...
];
Option 3.
Another option would be to use a custom EntityResolverProvider (we went down this path)
$this->app->bind(EntityResolverProvider::class, CustomEntityResolverProvider::class);
- Dominant language
- PHP
- Stars
- 3.5k
- Forks
- 468
- Avg merge
- 3h 9m
- Merged PRs (30d)
- 2
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.
More from nuwave/lighthouse
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
nuwave/lighthouse#2789 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
nuwave/lighthouse#2782 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
nuwave/lighthouse#2758 ·
-
bug
Difficulty 5/5 Over a week Newbie friendliness 35/100
nuwave/lighthouse#2744 ·
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 35/100
nuwave/lighthouse#2734 · 3 comments ·
All issues in nuwave/lighthouse
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
getgrav/grav-plugin-api#45 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
RSS-Bridge/rss-bridge#5098 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
phingofficial/phing#2025 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
silverstripe/developer-docs#911 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100