GraphQL: Product and User
Two GraphQL shapes generated from the same map as the Rust structs and the Google Merchant Center chapter. Product attributes follow Google’s product data specification.
Producthas one field per Merchant attribute, named and typed like the Merchant API v1 product input (price: Moneyin micros,availability: Availability,gtins: [String!]). 18 of its fields are machine data.Useris the customer: KNA1 with its address and default e-mail, and the consent ledger. 5 of its fields are personal data, soUseris a separate type: nothing personal is reachable fromProduct, and nothing inUseris sent to Merchant Center.
Every field carries @source(ecc: [...], origin: ...), so a resolver, a reviewer or an agent can see where a value comes from and whether it may be rewritten. marketingOptIn is @deprecated: it is a flag a nightly batch can overwrite, so clients read consent (newest row per purpose wins) instead.
Fields
| Type | Field | GraphQL type | Origin | ECC source |
|---|---|---|---|---|
Product | offerId | ID! | machine | MARA-MATNR |
Product | title | String | MAKT-MAKTXMAKT-SPRAS | |
Product | description | String | ||
Product | link | String | none | |
Product | imageLink | String | none | |
Product | availability | Availability | machine | MARD-LABSTMARD-INSMEMARD-SPEME |
Product | price | Money | machine | A004-KSCHLA004-DATABA004-DATBIKONP-KBETRKONP-KPEINKONP-KONWAKONP-LOEVM_KOTCURX-CURRDEC |
Product | salePrice | Money | machine | A004-KSCHLA004-DATABA004-DATBIKONP-KBETRKONP-KPEINKONP-KONWATCURX-CURRDEC |
Product | salePriceEffectiveDate | DateInterval | machine | A004-DATABA004-DATBI |
Product | costOfGoodsSold | Money | machine | MBEW-VPRSVMBEW-STPRSMBEW-VERPRMBEW-PEINH |
Product | unitPricingMeasure | Measure | machine | MARA-INHALMARA-INHME |
Product | googleProductCategory | String | MARA-MATKL | |
Product | productTypes | [String!] | machine | MARA-PRDHAT179T-PRODHT179T-VTEXT |
Product | brand | String | MARA-MFRNR | |
Product | gtins | [String!] | machine | MARM-EAN11MARM-NUMTPMARA-EAN11MARA-NUMTP |
Product | mpn | String | machine | MARA-MFRPN |
Product | identifierExists | Boolean | machine | MARA-EAN11MARA-MFRPN |
Product | itemGroupId | String | machine | MARA-SATNR |
Product | material | String | MARA-WRKST | |
Product | color | String | ||
Product | condition | Condition | none | |
Product | productWeight | Measure | machine | MARA-NTGEWMARA-GEWEI |
Product | shippingWeight | Measure | machine | MARA-BRGEWMARA-GEWEI |
Product | shippingLength | Measure | machine | MARM-LAENGMARM-MEABM |
Product | shippingWidth | Measure | machine | MARM-BREITMARM-MEABM |
Product | shippingHeight | Measure | machine | MARM-HOEHEMARM-MEABM |
Product | shipsFromCountry | String | machine | T001W-LAND1 |
User | id | ID! | machine | KNA1-KUNNR |
User | name | String | personal | KNA1-NAME1 |
User | email | String | personal | ADR6-SMTP_ADDRADR6-FLGDEFAULTADR6-FLG_NOUSE |
User | phone | String | personal | ADRC-TEL_NUMBER |
User | city | String | personal | KNA1-ORT01 |
User | postalCode | String | personal | KNA1-PSTLZ |
User | region | String | machine | KNA1-REGIO |
User | country | String! | machine | KNA1-LAND1 |
User | language | String | machine | KNA1-SPRAS |
User | createdOn | Date | machine | KNA1-ERDAT |
User | deleted | Boolean! | machine | KNA1-LOEVM |
User | gpcSeen | Boolean | machine | KNA1-/ACME/GPC |
User | marketingOptIn | Boolean | machine | KNA1-ZZ_MKT_OPTIN |
User | consent | [Consent!]! | machine | /ACME/CONSENT |
Schema
schema.graphql in the repository; tests/graphql.rs parses it.
# @generated from site/ddic.json by src/codegen.rs. Do not edit.
"""Where a field's value comes from, and who may change it."""
directive @source(
"""Attribute name in the product data specification."""
attribute: String
"""ECC tables and fields it is converted from."""
ecc: [String!]!
origin: Origin!
) on FIELD_DEFINITION
enum Origin {
"""A code, identifier, amount, unit, date or quantity ECC holds: converted by rule, never rewritten."""
MACHINE
"""Text a person writes. AI-written text must be declared (digital_source_type)."""
AUTHORED
"""Owned by another system."""
NONE
"""Personal data: served only to the customer or a permitted purpose, never sent to Merchant Center."""
PERSONAL
}
scalar Date
scalar DateTime
"""A product, shaped like a Merchant API v1 product input. Attributes: https://support.google.com/merchants/answer/7052112"""
type Product {
"""ISO 639-1, e.g. en."""
contentLanguage: String!
"""A-Z, 0-9, - and _; up to 20."""
feedLabel: String!
offerId: ID! @source(attribute: "id", ecc: ["MARA-MATNR"], origin: MACHINE)
title: String @source(attribute: "title", ecc: ["MAKT-MAKTX", "MAKT-SPRAS"], origin: AUTHORED)
description: String @source(attribute: "description", ecc: [], origin: AUTHORED)
link: String @source(attribute: "link", ecc: [], origin: NONE)
imageLink: String @source(attribute: "image_link", ecc: [], origin: NONE)
availability: Availability @source(attribute: "availability", ecc: ["MARD-LABST", "MARD-INSME", "MARD-SPEME"], origin: MACHINE)
price: Money @source(attribute: "price", ecc: ["A004-KSCHL", "A004-DATAB", "A004-DATBI", "KONP-KBETR", "KONP-KPEIN", "KONP-KONWA", "KONP-LOEVM_KO", "TCURX-CURRDEC"], origin: MACHINE)
salePrice: Money @source(attribute: "sale_price", ecc: ["A004-KSCHL", "A004-DATAB", "A004-DATBI", "KONP-KBETR", "KONP-KPEIN", "KONP-KONWA", "TCURX-CURRDEC"], origin: MACHINE)
salePriceEffectiveDate: DateInterval @source(attribute: "sale_price_effective_date", ecc: ["A004-DATAB", "A004-DATBI"], origin: MACHINE)
costOfGoodsSold: Money @source(attribute: "cost_of_goods_sold", ecc: ["MBEW-VPRSV", "MBEW-STPRS", "MBEW-VERPR", "MBEW-PEINH"], origin: MACHINE)
unitPricingMeasure: Measure @source(attribute: "unit_pricing_measure", ecc: ["MARA-INHAL", "MARA-INHME"], origin: MACHINE)
googleProductCategory: String @source(attribute: "google_product_category", ecc: ["MARA-MATKL"], origin: AUTHORED)
productTypes: [String!] @source(attribute: "product_type", ecc: ["MARA-PRDHA", "T179T-PRODH", "T179T-VTEXT"], origin: MACHINE)
brand: String @source(attribute: "brand", ecc: ["MARA-MFRNR"], origin: AUTHORED)
gtins: [String!] @source(attribute: "gtin", ecc: ["MARM-EAN11", "MARM-NUMTP", "MARA-EAN11", "MARA-NUMTP"], origin: MACHINE)
mpn: String @source(attribute: "mpn", ecc: ["MARA-MFRPN"], origin: MACHINE)
identifierExists: Boolean @source(attribute: "identifier_exists", ecc: ["MARA-EAN11", "MARA-MFRPN"], origin: MACHINE)
itemGroupId: String @source(attribute: "item_group_id", ecc: ["MARA-SATNR"], origin: MACHINE)
material: String @source(attribute: "material", ecc: ["MARA-WRKST"], origin: AUTHORED)
color: String @source(attribute: "color", ecc: [], origin: AUTHORED)
condition: Condition @source(attribute: "condition", ecc: [], origin: NONE)
productWeight: Measure @source(attribute: "product_weight", ecc: ["MARA-NTGEW", "MARA-GEWEI"], origin: MACHINE)
shippingWeight: Measure @source(attribute: "shipping_weight", ecc: ["MARA-BRGEW", "MARA-GEWEI"], origin: MACHINE)
shippingLength: Measure @source(attribute: "shipping_length", ecc: ["MARM-LAENG", "MARM-MEABM"], origin: MACHINE)
shippingWidth: Measure @source(attribute: "shipping_width", ecc: ["MARM-BREIT", "MARM-MEABM"], origin: MACHINE)
shippingHeight: Measure @source(attribute: "shipping_height", ecc: ["MARM-HOEHE", "MARM-MEABM"], origin: MACHINE)
shipsFromCountry: String @source(attribute: "ships_from_country", ecc: ["T001W-LAND1"], origin: MACHINE)
"""Newest change document for the material (CDHDR), YYYYMMDDhhmmss: an older write can't replace a newer one."""
versionNumber: String @source(ecc: ["CDHDR-UDATE", "CDHDR-UTIME"], origin: MACHINE)
}
"""Micros: 1 000 000 = one unit of the currency. KRW and JPY are already shifted from SAP's 2 stored decimals."""
type Money {
amountMicros: String!
"""ISO 4217."""
currencyCode: String!
}
"""UTC; endTime is exclusive."""
type DateInterval {
startTime: DateTime!
endTime: DateTime!
}
type Measure {
value: Float!
"""Google's unit: g, kg, oz, lb, cm, in, ml, l, ..."""
unit: String!
}
enum Availability {
IN_STOCK
OUT_OF_STOCK
PREORDER
BACKORDER
LIMITED_AVAILABILITY
}
enum Condition {
NEW
USED
REFURBISHED
}
"""A customer (KNA1 with its address and e-mail) and their consent. Personal data stays here: it is not part of Product."""
type User {
"""Customer number as SAP displays it (leading zeros dropped for all-digit numbers)."""
id: ID! @source(ecc: ["KNA1-KUNNR"], origin: MACHINE)
"""Name 1 of the customer master."""
name: String @source(ecc: ["KNA1-NAME1"], origin: PERSONAL)
"""The default e-mail address (FLGDEFAULT) that is not marked do-not-use (FLG_NOUSE); ADR6 is reached through KNA1-ADRNR."""
email: String @source(ecc: ["ADR6-SMTP_ADDR", "ADR6-FLGDEFAULT", "ADR6-FLG_NOUSE"], origin: PERSONAL)
"""Telephone from the business address."""
phone: String @source(ecc: ["ADRC-TEL_NUMBER"], origin: PERSONAL)
"""City."""
city: String @source(ecc: ["KNA1-ORT01"], origin: PERSONAL)
"""Postal code."""
postalCode: String @source(ecc: ["KNA1-PSTLZ"], origin: PERSONAL)
"""Region code (ISO 3166-2 subdivision once prefixed with the country)."""
region: String @source(ecc: ["KNA1-REGIO"], origin: MACHINE)
"""ISO 3166-1 alpha-2."""
country: String! @source(ecc: ["KNA1-LAND1"], origin: MACHINE)
"""BCP 47 from the one-character SAP language key (E → en / 3 → ko)."""
language: String @source(ecc: ["KNA1-SPRAS"], origin: MACHINE)
"""Created on."""
createdOn: Date @source(ecc: ["KNA1-ERDAT"], origin: MACHINE)
"""Central deletion flag: a deleted customer is not served."""
deleted: Boolean! @source(ecc: ["KNA1-LOEVM"], origin: MACHINE)
"""Global Privacy Control was received."""
gpcSeen: Boolean @source(ecc: ["KNA1-/ACME/GPC"], origin: MACHINE)
marketingOptIn: Boolean @source(ecc: ["KNA1-ZZ_MKT_OPTIN"], origin: MACHINE) @deprecated(reason: "a flag a batch job can overwrite. Read consent instead.")
"""The append-only consent ledger for this customer; the newest row per purpose wins."""
consent: [Consent!]! @source(ecc: ["/ACME/CONSENT"], origin: MACHINE)
}
"""One row of /ACME/CONSENT: append-only, the newest row per purpose wins."""
type Consent {
purpose: String! @source(ecc: ["/ACME/CONSENT-PURPOSE"], origin: MACHINE)
recordedAt: DateTime! @source(ecc: ["/ACME/CONSENT-RECORDED_AT"], origin: MACHINE)
granted: Boolean! @source(ecc: ["/ACME/CONSENT-GRANTED"], origin: MACHINE)
source: String @source(ecc: ["/ACME/CONSENT-SOURCE"], origin: MACHINE)
seqno: Int @source(ecc: ["/ACME/CONSENT-SEQNO"], origin: MACHINE)
}
type Query {
product(offerId: ID!, contentLanguage: String!, feedLabel: String!): Product
"""Served only to the customer themself or for a permitted purpose."""
user(id: ID!): User
}
Example
The same sample material as the Merchant chapter, and the sample customer from fixtures/records/kna1.json, adr6.json and acme_consent.json. tests/graphql.rs checks that every key in these responses is a field of the schema.
query {
product(offerId: "HM-QUEEN-01", contentLanguage: "en", feedLabel: "US") {
offerId title availability
price { amountMicros currencyCode }
salePrice { amountMicros currencyCode }
salePriceEffectiveDate { startTime endTime }
gtins mpn identifierExists productTypes
shippingWeight { value unit }
shipsFromCountry versionNumber
}
}
{
"data": {
"product": {
"availability": "IN_STOCK",
"gtins": [
"012345678905"
],
"identifierExists": true,
"mpn": "HM-Q-2026",
"offerId": "HM-QUEEN-01",
"price": {
"amountMicros": "129000000",
"currencyCode": "USD"
},
"productTypes": [
"Home > Heating > Heated mats"
],
"salePrice": {
"amountMicros": "109000000",
"currencyCode": "USD"
},
"salePriceEffectiveDate": {
"endTime": "2026-12-01T08:00:00Z",
"startTime": "2026-11-01T08:00:00Z"
},
"shippingWeight": {
"unit": "kg",
"value": 9.8
},
"shipsFromCountry": "US",
"title": "Heated mat, queen",
"versionNumber": "20261103021500"
}
}
}
query {
user(id: "12345") {
id name email country region language createdOn deleted gpcSeen marketingOptIn
consent { purpose recordedAt granted source seqno }
}
}
{
"data": {
"user": {
"consent": [
{
"granted": false,
"purpose": "ads",
"recordedAt": "2026-11-04T10:05:00Z",
"seqno": 0,
"source": "dsr"
},
{
"granted": true,
"purpose": "ads",
"recordedAt": "2026-11-04T10:02:00Z",
"seqno": 0,
"source": "banner"
}
],
"country": "US",
"createdOn": "2024-01-15",
"deleted": false,
"email": "orders@example.com",
"gpcSeen": false,
"id": "12345",
"language": "en",
"marketingOptIn": true,
"name": "Example Retail Inc.",
"region": "CA"
}
}
}
consent returns the ledger; the 10:05 withdrawal (dsr) is newer than the 10:02 grant, so ads consent is withdrawn. marketingOptIn still says true: that is the stale batch-written flag the schema deprecates.