commerce icon indicating copy to clipboard operation
commerce copied to clipboard

[VENDURE] how to efficiently query a graphql backend based on needed data

Open biclighter81 opened this issue 3 years ago • 0 comments

Hello together, I'm using the vendure backend for handling my shop logic. After implementing a few new checkout query hooks I noticed a potential approach mistake by myself. The activeCustomer query of the vendure backend returns beside customer metadata like firstname, name, phone, etc. also all completed, failed and active orders (and a lot more). It would be possible to create an order overview just using the useCustomer hook. If i additionally add order items and some other sub selects to the graphql statement, the json backend response gets huge. But at some places in my application I just need a few of these datas. In my opinion this approach (fetching always everything) completely abuses the idea behind graphql. Can somebody tell me their approach for keeping graphql responses small? Should I create hooks for every sub select (f.e. useCustomerAddress, useOrders, useOrderLines, useProductVariants, etc.).

Thank you, sincerely Moritz

biclighter81 avatar Mar 17 '22 15:03 biclighter81