Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

GraphQL Joins #8720


User avatar
0
mahendra created

Hi, I have following two entities: Product id, desc, price, productgroupid ProductGroup id desc

As you can see, product entity has a reference id of product group (that is productgroupid). Now I have created a GraphQL that returns me the products. In this graphQL output I need the ProductGroup.desc and not the productgroupid. I mean I wanted to have joins. I already have two AppService (One for Product and one for ProductGroup created.

Can you please throw some hint on how to write joins in GraphQL. Would appreciate if you could provide some sample code...

Many Thanks, Mahendra


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @mahendra

    You can first include ProductGroup into your query as we did for User in this example;

    UserQuery.cs#L197

    After that, you can create a mapping to map ProductGroup.desc to your output DTO field here;

    CustomDtoMapper.cs