Search by

hryvinskyi / magento2-gdpr-graph-ql

hryvinskyi

GraphQL API of the data-subject rights (GDPR) suite: a signed-in customer requests an export, an erasure or an anonymisation of their data, lists, cancels and downloads their requests; a guest submits a claim for an order's e-mail address and confirms or cancels it with the e-mailed token.

Package info

github.com/hryvinskyi/magento2-gdpr-graph-ql

Type:magento2-module

pkg:composer/hryvinskyi/magento2-gdpr-graph-ql

Statistics

Installs: 1

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-11-30 18:52 UTC

This package is auto-updated.

Last update: 2026-11-30 20:07:22 UTC


README

The GraphQL surface of the data-subject rights suite: a customer's requests as a field of Customer, mutations to ask for an export, an erasure or an anonymisation and to cancel a request, and mutations for a shopper without an account. It implements no rule of its own. Each resolver calls a service of hryvinskyi/magento2-gdpr and turns its answer and its refusals into GraphQL.

What it does for a store

A headless storefront, or any client of the GraphQL endpoint, makes the same requests as the storefront pages do, with the same rules: the account's password for an erase or an anonymise, one open request of a kind, the website's delay, and the same generic answer for a guest whether or not the claim matches an order.

Requirements

  • Magento Open Source or Adobe Commerce 2.4.8 or 2.4.9, PHP 8.3 to 8.5.
  • hryvinskyi/magento2-gdpr-api ^1.0 and hryvinskyi/magento2-gdpr ^1.0.
  • The platform's Store, GraphQl, CustomerGraphQl and StoreGraphQl modules.

Installation

Run from the Magento root. hryvinskyi/magento2-gdpr-pack installs this package with the rest of the suite.

composer require hryvinskyi/magento2-gdpr-graph-ql
bin/magento module:enable Hryvinskyi_GdprApi Hryvinskyi_Clock Hryvinskyi_RateLimit Hryvinskyi_DocumentExport Hryvinskyi_Logger Hryvinskyi_Gdpr Hryvinskyi_GdprGraphQl
bin/magento setup:upgrade
bin/magento setup:di:compile  # production mode only
bin/magento cache:flush

Verify with a customer token. Replace <base_url> and <customer_token>.

curl -s '<base_url>/graphql' -H 'Content-Type: application/json' -H 'Authorization: Bearer <customer_token>' --data '{"query":"{ customer { gdpr_requests { request_id type status } } }"}'

A customer with no request gets an empty gdpr_requests list.

Configuration

None of its own. hryvinskyi_gdpr/general/enabled set to No for a store view refuses, with one fixed message, Customer.gdpr_requests and the customer mutations of every customer whose account belongs to that store view, whichever store view the request names, and submitGuestGdprRequest sent to that store view. confirmGuestGdprRequest and cancelGuestGdprRequest keep working, so a link already e-mailed does not die. The settings are described in the README of hryvinskyi/magento2-gdpr.

The schema

A request is a GdprRequest with request_id, type (EXPORT, ERASE, ANONYMISE), status (PENDING_CONFIRMATION, SCHEDULED, RUNNING, COMPLETED, FAILED, CANCELLED, EXPIRED), requested_at, respond_by, execute_after, finished_at, cancellable, archive_available and archive_expires_at. Times are ISO 8601 in UTC and respond_by is a date.

Operation Needs Does
Customer.gdpr_requests a customer token The signed-in customer's requests, newest first.
requestGdprExport a customer token Requests a copy of the customer's data.
requestGdprErasure(input: {type, password}) a customer token Requests an erase or an anonymise (type is ERASE or ANONYMISE), confirmed with the account's password.
cancelGdprRequest(requestId) a customer token Cancels one of the customer's requests while it waits for its run.
createGdprDownloadLink(requestId) a customer token Issues a new link to the export archive of one of the customer's requests.
submitGuestGdprRequest(input: {order_number, email, lastname, postcode, type}) the store view header A guest's claim. It always answers true, whether or not the claim matches an order; a match queues a confirmation e-mail to the order's address, which cron sends within minutes. A failure after the claim passed the checks of its form and of the rate limit is logged, without the address, and answered true as well.
confirmGuestGdprRequest(requestId, token) the store view header Confirms a guest's request with the token from its e-mail.
cancelGuestGdprRequest(requestId, token) the store view header Cancels it with the token, while it waits for confirmation or for its run.

A customer operation without a customer token is refused. A guest claim needs lastname or postcode.

mutation {
  requestGdprErasure(input: { type: ERASE, password: "<account_password>" }) {
    request_id
    status
    execute_after
  }
}

Refusals become GraphQL errors: an unknown or foreign request is not found, a wrong password and an account locked after too many wrong passwords are authentication errors, and every other refusal is an input error carrying the service's message. The arguments are named requestId; the field of a request keeps the name request_id.

Limits

  • The password of an erase or an anonymise travels in the mutation, so the endpoint must be served over HTTPS.
  • A guest submission is rate limited per client address and per order number. Behind a proxy that does not pass the client address on, every shopper shares one limit; configure the trusted proxy and forwarded header the store uses.
  • The mutations return the request; the work itself is carried out by cron after the website's delay.
  • The schema has no operation for an operator. Operators use the REST routes, the command line or the admin.

Registrations

Where What
etc/schema.graphqls The types, enums, inputs and operations above.
Resolvers Hryvinskyi\GdprGraphQl\Model\Resolver\CustomerRequests, RequestExport, RequestErasure, CancelRequest, CreateDownloadLink, SubmitGuestRequest, ConfirmGuestRequest and CancelGuestRequest

The package registers no preference, route, cron job, command or ACL resource.

Extension points

None of its own.

Tests

Run from the Magento root.

  • Unit: vendor/bin/phpunit -c app/code/Hryvinskyi/GdprGraphQl/phpunit.xml.dist.
  • Integration: the platform's harness in dev/tests/integration, against its own database, one run at a time. cd dev/tests/integration && php -d memory_limit=4G ../../../vendor/bin/phpunit -c phpunit.xml ../../../app/code/Hryvinskyi/GdprGraphQl/Test/Integration.
  • Static analysis: PHPStan 2.x at level 10 with the package's phpstan.neon.dist (phpstan analyse -c app/code/Hryvinskyi/GdprGraphQl/phpstan.neon.dist --level=10), and vendor/bin/phpcs --standard=app/code/Hryvinskyi/GdprGraphQl/phpcs.xml.dist app/code/Hryvinskyi/GdprGraphQl.

Translations

The messages the package shows ship in en_US and 25 more locales: the official languages of the European Union, Norwegian Bokmål and Ukrainian. The translations are machine-made; have them read by a native speaker before a store relies on them, and override a phrase in a theme or a language pack.