如何在GatsbyJS中设置GraphQL Endpoint



我正在用GatsbyJS尝试使用GraphQL。我有问题,弄清楚如何配置GraphQL端点为我的GatsbyJS应用程序查询。

我一直得到错误,我的查询无法找到:

如果你不期待"页"在"查询"类型上存在很可能是打错了。然而,如果你期望"页面"存在一些常见问题的解决方案:

这是我的GatsbyJS的repo。转到开发分支查看代码。

这是我试图查询的GraphQL端点。

我在Postman中进行了测试,并且能够检索到我想要的数据。

查询:

query {
pages(name: "Index") {
data {
name
title
subtitle
text
meta_title
meta_description
}
}
featured: posts(featured: true, first: 1) {
data {
title
summary
text
}
}
posts(first: 6) {
data {
title
}
}
}

输出:

{
"data": {
"pages": {
"data": [
{
"name": "Index",
"title": "The Beloved's Blog",
"subtitle": "So you also are complete through your union with Christ, who is the head over every ruler and authority.rnCol 2:10 NLT",
"text": null,
"meta_title": "The Beloved's Blog",
"meta_description": "A blog I maintain to store the personal testimonies and revelations I have."
}
]
},
"featured": {
"data": [
{
"title": "Jesus Made Us Unique",
"summary": "I’m sure most of us have felt pressured by the definitions of what it means to be “good in something”. It could come from the world, from our friends and families, or even from us. Eg. what it takes to be a good employee, a good person, a good mum/dad,...",
"text": "I’m sure most of us have felt pressured by the definitions of what it means to be “good in something”. It could come from the world, from our friends and families, or even from us. Eg. what it takes to be a good employee, a good person, a good mum/dad, or even a good Christian. “Oh, to be a good Christian, you need to be this; you need to be that. You need to do this; you need to do that.”rnrnBut we must remember that Jesus made us all unique. He has already put in each of us the gifts and grace to achieve and accomplish our callings. While we should be open to feedback, don’t let them define your identity. Whether or not you fit into the definitions of what it means to be good, you are forever loved and righteous in Jesus. rnrnEspecially when one desires to live for Jesus, one will face opposition from the devil. He wants to stop you from living a Jesus-life. So he will do all he can to oppose you; from negative thoughts and feelings to surrounding you with jealous people. rnrnJust like in this passage. When David was about to face Goliath, Saul tried to get David to wear his armour. Saul’s trust was in his armour, while David’s trust was in the Lord. From here you could see Saul subtly trying to put down David’s faith. But David resisted by taking off the armour and going in his anointing as a shepherd and not a warrior. rnrnHave you ever felt pressured before to be someone you are not? Run to Jesus. Let HIM tell you about you. Jesus is with you, and He has made each of you unique. Each one of you is precious and valuable to Him. He loves you immensely; every part of you… including your quirks!rnrnHope this has blessed you. Be blessed and stay blessed in Jesus’ amen."
}
]
},
"posts": {
"data": [
{
"title": "We Are Under the New Covenant"
},
{
"title": "Jesus Helps Me in My Coding"
},
{
"title": "Thank You Jesus for Your Productivity and Wisdom in My Life"
},
{
"title": "Jesus Made Us Unique"
},
{
"title": "A Week of Rest & Acceleration"
},
{
"title": "Review Went Well and Received an Increment"
}
]
}
}
}

终于在这一页找到了我需要的东西。

发布这篇文章,以防其他人遇到和我一样的问题。

最新更新