Rust structs and GraphQL types
The same field in each shape it takes: the GraphQL type a client or agent reads, the Rust struct that holds it after
conversion, and the ECC fields it comes from. The GraphQL side is schema.graphql; the Rust side is
src/merchant.rs and src/merchant_api.rs for products and the generated sap::* and acme::* structs for customers.
Origin follows the book’s rule: machine data is converted by a fixed rule and never rewritten, text may be written by people or declared AI, none comes from another system, and personal data never reaches Merchant Center.
Product
Two Rust structs: merchant::Product is the converted ECC record (amounts as Decimal, dates as chrono), and
merchant_api::ProductInput is what the Merchant API v1 receives (amounts in micros as strings, enums upper case).
merchant_api::product_input turns one into the other; tests/merchant_api.rs checks every path.
| GraphQL field | GraphQL type | merchant::Product (converted) | merchant_api::ProductInput (sent) | Origin | ECC source |
|---|---|---|---|---|---|
offerId | ID! | id: String | offer_id: String | machine | MARA-MATNR |
contentLanguage | String! | (feed setting) | content_language: String | ||
feedLabel | String! | (feed setting) | feed_label: String | ||
title | String | title: Option<String> | title: Option<String> | MAKT-MAKTX, MAKT-SPRAS | |
availability | Availability | in_stock: bool | availability: &'static str (IN_STOCK / OUT_OF_STOCK) | machine | MARD-LABST, MARD-INSME, MARD-SPEME |
price | Money | price: Option<Money> (amount: Decimal, currency: String, decimals: u32) | price: Option<Price> (amount_micros: String, currency_code: String) | machine | A004, KONP, TCURX-CURRDEC |
salePrice | Money | sale_price: Option<Money> | sale_price: Option<Price> | machine | A004, KONP, TCURX-CURRDEC |
salePriceEffectiveDate | DateInterval | sale_window: Option<(NaiveDate, NaiveDate, FixedOffset)> (inclusive, local) | sale_price_effective_date: Option<Interval> (UTC, end exclusive) | machine | A004-DATAB, A004-DATBI |
costOfGoodsSold | Money | cost: Option<Money> | cost_of_goods_sold: Option<Price> | machine | MBEW-VPRSV, MBEW-STPRS, MBEW-VERPR, MBEW-PEINH |
unitPricingMeasure | Measure | unit_pricing: Option<Measure> (value: Decimal, unit) | unit_pricing_measure: Option<ValueUnit> (value: f64, unit) | machine | MARA-INHAL, MARA-INHME |
productTypes | [String!] | product_type: Option<String> | product_types: Vec<String> | machine | MARA-PRDHA, T179T-VTEXT |
gtins | [String!] | gtin: Option<String> | gtins: Vec<String> | machine | MARM-EAN11, MARM-NUMTP, MARA-EAN11, MARA-NUMTP |
mpn | String | mpn: Option<String> | mpn: Option<String> | machine | MARA-MFRPN |
identifierExists | Boolean | derived: identifier_exists() | identifier_exists: Option<bool> (sent only as false) | machine | MARA-EAN11, MARA-MFRPN |
itemGroupId | String | item_group_id: Option<String> | item_group_id: Option<String> | machine | MARA-SATNR |
material | String | material: Option<String> | material: Option<String> | MARA-WRKST | |
productWeight | Measure | product_weight: Option<Measure> | product_weight: Option<ValueUnit> | machine | MARA-NTGEW, MARA-GEWEI |
shippingWeight | Measure | shipping_weight: Option<Measure> | shipping_weight: Option<ValueUnit> | machine | MARA-BRGEW, MARA-GEWEI |
shippingLength | Measure | shipping_dims: Option<[Measure; 3]>, [0] | shipping_length: Option<ValueUnit> | machine | MARM-LAENG, MARM-MEABM |
shippingWidth | Measure | shipping_dims, [1] | shipping_width: Option<ValueUnit> | machine | MARM-BREIT, MARM-MEABM |
shippingHeight | Measure | shipping_dims, [2] | shipping_height: Option<ValueUnit> | machine | MARM-HOEHE, MARM-MEABM |
shipsFromCountry | String (ISO 3166-1 alpha-2) | ships_from_country: Option<String> | custom_attributes: Vec<CustomAttribute> (name, value) | machine | T001W-LAND1 |
versionNumber | String | version: Option<i64> (YYYYMMDDhhmmss) | version_number: Option<String> | machine | CDHDR-UDATE, CDHDR-UTIME |
description, googleProductCategory, brand, color | String | not held | not sent from ECC | written by people, or AI if declared | |
link, imageLink, condition | String, String, Condition | not held | not sent from ECC | none | storefront, DAM |
User
There is no single Rust User struct. User in GraphQL is assembled from the generated table structs, so each field
keeps the type its DDIC field has; the resolver joins them on KNA1-ADRNR = ADDRNUMBER.
| GraphQL field | GraphQL type | Rust struct and field | Rust type | Origin | ECC source |
|---|---|---|---|---|---|
id | ID! | sap::Kna1.kunnr | String | machine | KNA1-KUNNR |
name | String | sap::Kna1.name1 | String | personal | KNA1-NAME1 |
email | String | sap::Adr6.smtp_addr, where flgdefault and not flg_nouse | String, bool, bool | personal | ADR6-SMTP_ADDR, ADR6-FLGDEFAULT, ADR6-FLG_NOUSE |
phone | String | sap::Adrc.tel_number | String | personal | ADRC-TEL_NUMBER |
city | String | sap::Kna1.ort01 | String | personal | KNA1-ORT01 |
postalCode | String | sap::Kna1.pstlz | String | personal | KNA1-PSTLZ |
region | String | sap::Kna1.regio | String | machine | KNA1-REGIO |
country | String! | sap::Kna1.land1 | String | machine | KNA1-LAND1 |
language | String | sap::Kna1.spras (E → en, 3 → ko) | String | machine | KNA1-SPRAS |
createdOn | Date | sap::Kna1.erdat | Option<chrono::NaiveDate> | machine | KNA1-ERDAT |
deleted | Boolean! | sap::Kna1.loevm | bool | machine | KNA1-LOEVM |
gpcSeen | Boolean | sap::Kna1.acme_gpc | bool | machine | KNA1-/ACME/GPC |
marketingOptIn (deprecated) | Boolean | sap::Kna1.zz_mkt_optin | bool | machine | KNA1-ZZ_MKT_OPTIN |
consent | [Consent!]! | Vec<acme::Consent> for the customer | see below | machine | /ACME/CONSENT |
Consent
| GraphQL field | GraphQL type | Rust struct and field | Rust type | ECC source |
|---|---|---|---|---|
purpose | String! | acme::Consent.purpose | String | /ACME/CONSENT-PURPOSE |
recordedAt | DateTime! | acme::Consent.recorded_at | Option<chrono::NaiveDateTime> | /ACME/CONSENT-RECORDED_AT |
granted | Boolean! | acme::Consent.granted | bool | /ACME/CONSENT-GRANTED |
source | String | acme::Consent.source | String | /ACME/CONSENT-SOURCE |
seqno | Int | acme::Consent.seqno | i32 | /ACME/CONSENT-SEQNO |
Google Merchant endpoints: product, loyalty, comparison shopping, reviews
Where each record goes in Google, and what of it this book builds. All four use the https://www.googleapis.com/auth/content
OAuth scope, and every write names a data source (accounts/{account}/dataSources/{dataSource}).
| Endpoint | Method and path | Version | Rust struct | GraphQL | What it carries | Here |
|---|---|---|---|---|---|---|
| Product | POST https://merchantapi.googleapis.com/products/v1/{parent=accounts/*}/productInputs:insert?dataSource=...; the processed product is read back with GET .../products/v1/accounts/{account}/products/{contentLanguage~feedLabel~offerId} | v1 | merchant_api::ProductInput | Product | The converted ECC product: identifiers, prices, stock, units, dimensions, versionNumber | Built: src/merchant_api.rs, tests/merchant_api.rs. Nothing sends yet. |
| Loyalty | No endpoint of its own: productAttributes.loyaltyPrograms[] on the same productInputs:insert. Loyalty shipping is set on accounts/{account}/shippingSettings. The program must first be linked in Merchant Center. | v1 | not built: would be ProductAttributes.loyalty_programs: Vec<LoyaltyProgram> | not built: would be Product.loyaltyPrograms | Per tier: programLabel, tierLabel, member price (no higher than the regular price), cashbackForFutureUse, loyaltyPoints, memberPriceEffectiveDate, shippingLabel | Not built. A member price would come from its own SAP condition type, converted like price. Program data, not personal data: who is a member stays on User. |
| Comparison shopping | POST https://css.googleapis.com/v1/{parent=accounts/*}/cssProductInputs:insert: the separate CSS API, for comparison shopping services listing other merchants’ products | v1 | not built | not built | A product input keyed by contentLanguage, feedLabel (the target country, e.g. DE) and identity; feedId is deprecated | Not built. Applies only when acting as, or supplying, a comparison shopping service. One-time API registration required. |
| Reviews | POST https://merchantapi.googleapis.com/reviews/v1beta/{parent=accounts/*}/productReviews:insert?dataSource=... and .../merchantReviews:insert?dataSource=..., with get, list and delete | v1beta | not built | not built | Rating, title, content, review time, language and country, isVerifiedPurchase, isIncentivizedReview, and the reviewer (reviewerId, reviewerUsername, isAnonymous) | Not built. Reviews come from the storefront or a review platform, not ECC. The reviewer is personal data: it belongs with User, under consent, never in Product. Requires a review data source and enrolment in the product ratings programme. |
Two rules follow from the table:
- Loyalty and reviews ride on the product, not the person. A member price is a fact about the product and the tier;
a review is attached to the product’s identifiers. The person behind either (the member, the reviewer) stays on
User, and leaves only through the release gate. - Beta means it can change. Reviews are
v1beta; Google says beta versions are subject to change or removal. Product and loyalty are onv1.
Sources: Products: add and manage, ProductAttributes (v1), including loyaltyPrograms, loyalty_program in the product data specification, CSS API: cssProductInputs.insert, Reviews: product reviews, Reviews: merchant reviews, Merchant API design and versioning.
Where the types differ, and why
- Amounts:
Decimalin Rust keeps SAP’s scale exactly (258.00); GraphQL and the Merchant API carry micros as a string, becauseint64doesn’t fit a JSON number safely. - Dates: Rust holds what ECC means (a local sale window, inclusive); the API gets UTC with an exclusive end.
- Lists: ECC holds one GTIN and one product type per row; Google takes lists, so the converter wraps them.
- Optional vs required: ABAP has no null. A Rust
OptionisNoneonly where ECC’s initial value means “not set” (00000000dates); GraphQL’s non-null!marks the fields a resolver must always return. - Personal data: only
Userholds it. Nothing inProduct,merchant::ProductorProductInputcan carry a name, e-mail or phone, so a product feed can’t leak one.