Skip to content

[GraphQL] Ability to define item get operation without any arguments #2527

@SCIF

Description

@SCIF

These days it's impossible to define an item operation for resource without argument. At least id will be added automatically.

The code:

/**
 * @ApiResource()
 */
class User

A query generated in the schema:

user(id: ID): User

Proposal

To achieve generation of user: User query we can add next notation:

 * @ApiResource(
 *     graphql={
 *      "query"={"withoutId", "controller"=ViewerController::class}

SchemaBuilder will prevent using withoutId annotation without custom controller specified.

Motivation

GraphQL can serves not only «batch»/relation requests but provide a way to implement very high level of semantic of API designed. It allows developer to design API in the most correct form and prevent creation of useless operations/endpoints.
Api-platform is desinged to simplify creation of API as much as it possible, so implementing custom operations using #2445 looks really overkill.

Any other ideas? Thanks!

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