Skip to content

Duplicate GraphQL field name if several foreignkeys have the same name in database #41

Description

@WizMik

Let say I have a database with a table A, B and C.
B and C have a field named A_id which is a foreign key pointing to A.

In GraphQL, I want to access the field A inside my BType and CType with the name "aValue".
To do that, I add the following comment to B.A_id and C.A_id fields in database :
@TheCodingMachine\GraphQLite\Annotations\Field(name="aValue")

Problem :
When running bin/console tdbm:generate, TDBM-GraphQL generates AbstractA.php Bean and adds the annotation @GraphqlField (name = "aValue") twice ! Once for AbstractA::getBs() and a second time for AbstractA::getCs().

This leads to the following error :
TheCodingMachine\GraphQLite\Mappers\DuplicateMappingException: The query/mutation/field "aValue" is declared twice in class 'App\Bean\A'. First in 'App\Bean\Generated\AbstractA::getBs()', second in 'App\Bean\Generated\AbstractA::getCs()' in file /var/www/html/vendor/thecodingmachine/graphqlite/src/Mappers/DuplicateMappingException.php on line 36

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions