core icon indicating copy to clipboard operation
core copied to clipboard

[GraphQL] ID field is added although not specified

Open codedge opened this issue 2 years ago • 8 comments

API Platform version(s) affected: 3.1.2

Description
When defining a new type, an ID field is automatically added to the generate schema. This should not be the case.

How to reproduce

Take the following entity as example:

Entity

#[
    API\ApiResource(
        graphQlOperations: [
            new Query(
                args: [],
            ),
        ]
    )
]
class Service
{
    #[
        API\ApiProperty(identifier: true),
        Assert\NotNull,
    ]
    private string $name = "abc-123";
    #[
        Assert\NotNull,
    ]
    private string $version = "0.1.0";
    #[
        Assert\NotNull,
    ]
    private string $schema = "";

   // .. getter/setter
}

This generates the following schema

2023-03-15_13 55 46

As you can see, the ID is in the schema but it is not defined. An external service is checking this schema, and does not allow this field to be there.

Possible Solution

A new type can be configure to not implement the Node interface. That is where the id fiel is coming from.

Additional Context

codedge avatar Mar 15 '23 12:03 codedge

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar May 15 '23 10:05 stale[bot]

Bump

codedge avatar May 16 '23 08:05 codedge

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 15 '23 10:07 stale[bot]

Bump

codedge avatar Jul 16 '23 12:07 codedge

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 15 '23 05:09 stale[bot]

Bump

codedge avatar Sep 17 '23 18:09 codedge

I don't see where this has been merged. Why has this been closed?

codedge avatar Sep 25 '23 14:09 codedge

Because of how our internals are working I guess we always need an id:ID ? this is probably fixable feel free to open a patch

soyuka avatar Jan 17 '24 14:01 soyuka