Загрузка данных
// старый запрос, надо от него избавиться
export const getWineInfo = ({
slug,
}) => {
return JSON.stringify({
variables: {
slug
},
query: `
query getWineInfo(
$slug: String!
) {
productBySlug(slug: $slug) {
id
slug
wine {
tradeName {
tradeName
}
brand {
name
}
keyWords
specialClassifications {
name
}
vintage
country {
localizedName(localeId: 1)
codeISO
}
geoIndications {
localizedName(localeId: 1)
}
nationalGIType {
localizedShortName(localeId: 1)
}
rating
wineType {
localizedName(localeId: 1)
}
sweetnessLevel {
localizedName(localeId: 1)
}
wineColor {
localizedName(localeId: 1)
}
}
bottleSize {
volumeML
}
bottleImage {
imageUrl
}
}
}
`
});
};
// новый запрос с полными данными о продуктах
export const userTastingsPagination = ({
page = 1,
perPage = 20,
currencyCode = "GBP",
countryId = 37,
}) => {
return JSON.stringify({
variables: {
page,
perPage,
currencyCode,
countryId,
},
query: `
query userTastingsPagination(
$page: PositiveInt! = 1
$perPage: PositiveInt! = 20
$localeId: Int! = 1,
$currencyCode: String,
$countryId: Int,
) {
me {
tastingsPagination(page: $page, perPage: $perPage) {
pageInfo {
hasNextPage
page
perPage
}
items {
id
score
recognition {
id
images {
imageUrl(
transformations: {width: 192, height: 192, resize: fit}
)
}
createdAt
product {
slug
bottleSize {
volumeML
}
packageType {
shortName
}
tradeOfferLotCount(filter: { countryId: $countryId })
maximumTradeOfferLot(filter: { countryId: $countryId }) {
pricePerBottle: price(wineLotId: 1, currencyCode: $currencyCode)
price(currencyCode: $currencyCode)
}
minimalTradeOfferLot(filter: { countryId: $countryId }) {
pricePerBottle: price(wineLotId: 1, currencyCode: $currencyCode)
price(currencyCode: $currencyCode)
}
wine {
...WineInfo
}
}
productDraft {
bottleSize {
volumeML
}
packageType {
shortName
}
wine {
...WineInfo
...WineDraftInfo
}
}
}
}
}
}
}
fragment WineInfo on Wine {
keyWords
tradeName {
tradeName
}
brand {
name
}
wineType {
localizedName(localeId: $localeId)
}
wineColor {
localizedName(localeId: $localeId)
}
sweetnessLevel {
localizedName(localeId: $localeId)
}
country {
codeISO
localizedName(localeId: $localeId)
}
nationalGIType {
localizedShortName(localeId: $localeId)
}
geoIndications {
localizedName(localeId: $localeId)
}
specialClassifications {
name
}
vintageText
rating
}
fragment WineDraftInfo on WineDraft {
keyWords
tradeName {
tradeName
}
brand {
name
}
wineType {
localizedName(localeId: $localeId)
}
wineColor {
localizedName(localeId: $localeId)
}
sweetnessLevel {
localizedName(localeId: $localeId)
}
country {
codeISO
localizedName(localeId: $localeId)
}
nationalGIType {
localizedShortName(localeId: $localeId)
}
geoIndications {
localizedName(localeId: $localeId)
}
specialClassifications {
name
}
vintageTextDraft: vintageText
isVintageUnknown
}
`
});
};
// оставление оценки о дегустации
//
// где input
// {
// "tastingId": 1,
// "score": 5
// }
export const userTastingUpdate = ({
input
}) => {
return JSON.stringify({
variables: {
input
},
query: `
mutation tastingUpdate($input: TastingUpdateInput!) {
tastingUpdate(input: $input) {
record {
id
score
}
}
}
`
});
};