id プロパティを持つオブジェクト タイプは、同じ id を指定して同じコンテンツを持たなければならないかどうか疑問に思っていました。現時点では、同じ ID に異なるコンテンツを含めることができます。
次のクエリ:
const query = gql`
query products(
$priceSelector: PriceSelectorInput!
) {
productProjectionSearch(
priceSelector: $priceSelector
) {
total
results {
masterVariant {
# If you do the following it will work
# anythingButId: id
id
scopedPrice {
country
}
}
}
}
}
`;
の場合、結果は次のようになりますPriceSelectorInput
。{currency: "USD", country: "US"}
{
"productProjectionSearch": {
"total": 2702,
"results": [
{
"name": "Sweater Pinko white",
"masterVariant": {
"id": 1,
"scopedPrice": {
"country": "US",
"__typename": "ScopedPrice"
},
"__typename": "ProductSearchVariant"
},
"__typename": "ProductProjection"
}
],
"__typename": "ProductProjectionSearchResult"
}
}
の場合、結果は次のようになりますPriceSelectorInput
。{currency: "EUR", country: "DE"}
{
"productProjectionSearch": {
"total": 2702,
"results": [
{
"name": "Sweater Pinko white",
"masterVariant": {
"id": 1,
"scopedPrice": {
"country": "DE",
"__typename": "ScopedPrice"
},
"__typename": "ProductSearchVariant"
},
"__typename": "ProductProjection"
}
],
"__typename": "ProductProjectionSearchResult"
}
}
私の質問は、タイプ ProductSearchVariant の masterVariant の id はどちらの場合も 1 ですが、scopedPrice の値が異なるということです。これは、このレポで示されているように、apollo キャッシュの defaultDataIdFromObject 関数を壊します。私の質問は; これは apollo のバグですか、それとも ProductSearchVariant の型定義における graphql 標準に違反しているのでしょうか?