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 ?
3
I think for GraphQL, you should use a Resolver instead of a Provider, look at the documentation: api-platform.com/docs/v2.7/core/graphql/#custom-queries.
18 mins ago
I try that too but this does not change the schema either.
8 mins ago
Here is issues from 4 yours now which are still not resolved at this time. They talking about custom output in GraphQL : github.com/api-platform/core/issues/2754 github.com/api-platform/core/issues/2755 Not be able to do that in my API sound for me like a dead end for API Platform ><
6 mins ago