Get invoice
Karskip
Member Posts: 3
Hi
I am wanting to create an API to get all invoices for a specific customer.
At the moment I only have the example version which is no good as its all in pages and shows all invoices so I would have to loop through each one on each page which is not good.
I have tried a few different things but it does not seem to work. Does anyone have a running GraphQL example of how I can do this
Thanks.
Chris
0
Comments
Hello @Karskip ,
The example query is the right place to start. Depending upon how many invoices you have, you're going to have to come to terms with paging.
You can certainly filter invoices by customer. First, you'll need to get the CustomerId you want, then you can modify your query as follows (relative to the documented example):
query($businessId: ID!, $page: Int!, $pageSize: Int!)
becomesquery($businessId: ID!, $page: Int!, $pageSize: Int!, $customerId: ID!)
invoices(page: $page, pageSize: $pageSize)
becomesinvoices(page: $page, pageSize: $pageSize, customerId: $customerId)
"customerId": "<CUSTOMER_ID>",
).Hope that helps.
You are a star. Simple as that.
Thank you so much