Customer Documents GraphQL
The optional mageb2b/customerdocuments-graph-ql package exposes customer-facing document data for a headless storefront. Queries run in the current store and customer context; the package is not an administrator document-management API.
composer require mageb2b/customerdocuments-graph-ql:*
php bin/magento module:enable MageB2B_CustomerDocumentsGraphQl
php bin/magento setup:upgrade
Available operations
customerDocumentsreturns a paginated document list and supports filters.customerDocumentCategoriesreturns categories visible to the current customer.customerDocument(id: Int!)returns one accessible document.downloadCustomerDocument(documentId: Int!, password: String)prepares an allowed download and returns its result.
List filters include document name, description, product assignment, category, sidebar visibility, validity dates and creation date.
List example
query MyDocuments {
customerDocuments(pageSize: 20, currentPage: 1) {
items {
id
name
description
has_password
is_downloadable
remaining_downloads
category {
id
name
}
}
total_count
page_info {
current_page
total_pages
}
}
}
Download example
mutation PrepareDocumentDownload($id: Int!, $password: String) {
downloadCustomerDocument(documentId: $id, password: $password) {
success
message
download_url
remaining_downloads
}
}
Send the buyer's customer token with requests that access private documents. Do not cache one customer's response for another customer. The download mutation still enforces access, website, validity, password and download-limit rules.