flutter应用中的店面api shopify(“节点”'nodes; amp;;
我的需求很简单。
我想使用Flutter查询Shopify的店面API,但是有一个捕获。
我的回答总是有多个节点和边缘。每个节点/边缘包含不同的对象。
现在,当我尝试在Android Studio中使用Jsontodart Generator并使用自己的模型创建每个类时,就会出现问题。包含不同的字段,它与其他节点类冲突。
屏幕截图附加了参考。 我想知道如何解决这个问题。
我的GraphQl查询是:
{
products(first: 2) {
nodes {
id
title
createdAt
description
descriptionHtml
featuredImage {
id
url
width
height
altText
}
onlineStoreUrl
options {
id
name
values
}
priceRange {
maxVariantPrice {
amount
currencyCode
}
minVariantPrice {
amount
currencyCode
}
}
productType
publishedAt
requiresSellingPlan
seo {
title
description
}
tags
totalInventory
updatedAt
vendor
images(first: 2) {
nodes {
id
url
width
height
altText
}
}
media(first: 2) {
nodes {
alt
mediaContentType
}
}
variants(first: 2) {
nodes {
availableForSale
barcode
id
image {
id
url
width
height
altText
}
requiresShipping
sku
title
weight
weightUnit
}
}
}
} }
My need is very simple.
I want to query Shopify's Storefront api using Flutter, but there is a catch.
My response always have multiple nodes and edges. and each node/edge containing different objects.
Now the problem arise when i try to use JsonToDart generator in android studio and it creates each class with its own model. containing different fields and it conflicts with the other Node class.
screenshot is attached for reference.
i want to know how i can tackle this problem.
my graphQL query is:
{
products(first: 2) {
nodes {
id
title
createdAt
description
descriptionHtml
featuredImage {
id
url
width
height
altText
}
onlineStoreUrl
options {
id
name
values
}
priceRange {
maxVariantPrice {
amount
currencyCode
}
minVariantPrice {
amount
currencyCode
}
}
productType
publishedAt
requiresSellingPlan
seo {
title
description
}
tags
totalInventory
updatedAt
vendor
images(first: 2) {
nodes {
id
url
width
height
altText
}
}
media(first: 2) {
nodes {
alt
mediaContentType
}
}
variants(first: 2) {
nodes {
availableForSale
barcode
id
image {
id
url
width
height
altText
}
requiresShipping
sku
title
weight
weightUnit
}
}
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不应以相同的方式使用多个类别,这会在您的代码中造成混乱,如果出于任何原因,则必须在不同的文件中定义它们,并且每当您将它们导入某个地方时,您都必须选择正确的文件才能导入它来自
You shouldn't have multiple classes called the same way, this creates confusion in your code, and if for any reason you do, they have to be defined in different files and whenever you import them somewhere you have to pick the right file to import it from