我正在努力弄清楚如何在 Gatsbyjs 中使用 GraphQL 查询多个特定图像。我最初的想法是做这样的事情:
file(relativePath: {eq: "images/front.jpg"}) {
id
}
file(relativePath: {eq: "images/front2.jpg"}) {
id
}
这会在 GraphQL 中引发错误:
{
"errors": [
{
"message": "Fields \"file\" conflict because they have differing arguments. Use different aliases on the fields to fetch both if this was intentional.",
"locations": [
{
"line": 28,
"column": 1
},
{
"line": 31,
"column": 1
}
]
}
]
}
查询一个特定的文件(图像)工作正常:
file(relativePath: {eq: "images/front.jpg"}) {
id
}
任何暗示我在这里做错了什么?谢谢 :)