Single Query or Multiple Query
Is it a good practice to combine unrelated models in a single GraphQL query in AEM, or should I create separate queries for each model?
Could you please share some insights on this
Is it a good practice to combine unrelated models in a single GraphQL query in AEM, or should I create separate queries for each model?
Could you please share some insights on this
When dealing with unrelated models in AEM, it's generally better to use multiple queries. This approach keeps things simple, avoids over-fetching data, and offers better flexibility for performance optimization and caching.
However, if the data from these models is needed together on the same page (and combining them in a single query helps reduce network overhead), then a single query might be justified. But, in most cases where the models are unrelated or used in different contexts, multiple queries are the cleaner and more maintainable choice.
Single Query (Combining Models)
Pros:
Cons
Multiple Queries (Separate Requests for Each Model)
Pros
Cons
Thanks and Regards,
Madhur
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.