API Platform custom GraphQL output

API Platform custom GraphQL output


0

I’m working on a GraphQL API using API Platform 2.7 and PHP8. I’m stuck since yersterday on a basic simple thing which is very annoying ><

I want to create a custom Query which does not return my ApiRessource class (User) but another representation (MyFullPerimeterOutput).
When I do it in REST API it works fine :

new Get(
    uriTemplate: 'users/my-full-perimeter',
    normalizationContext: [
        'groups' => ['user_my_full_perimeter'],
    ],
    output: MyFullPerimeterOutput::class,
    name: 'myFullPerimeter',
    provider: UserProvider::class,
),

But when I try to do the same thing in GraphQL Query, it seem the ouput config is not working >< I try many things and nothing works for now.

new Query(
    normalizationContext: [
        'groups' => ['user_my_full_perimeter'],
    ],
    security: "is_granted('ROLE_USER')",
    output: MyFullPerimeterOutput::class,
    name: 'myFullPerimeter',
    provider: UserProvider::class
),

When I go to GraphQL Playground, the query "myFullPerimeterUser" is part of the schema but still return "User" type and not MyFullPerimeterOutput.
Any idea of what I’m doing wrong ?

Share
Improve this question

3


Load 5 more related questions


Show fewer related questions

0

Reset to default



Leave a Reply

Your email address will not be published. Required fields are marked *