如何在mulesoft中使用HTTP请求器致电GraphQl API

发布于 2025-01-24 16:26:46 字数 525 浏览 1 评论 0原文

我需要在m子4中消耗GraphQl API。 我在DataWeave中的JSON代码下方起草,然后使用HTTP请求者发布有效载荷。 但是仍然返回无效语法,我可能知道可以将数据发布到GraphQl API 在m子4中?以下代码中的语法错误是什么?

%dw 2.0
output application/json
---
{
query: "query{
    test (first: 10, status: \"ACTIVE\" ) {
        edges {
            node {
                id
                ref
                type
                status
                attributes {
                    name
                    value
                    type
                }
            }
        }
    }"
}

I need to consume a graphQL API in Mule 4.
i draft below json code in dataweave, then use HTTP requestor to post the payload.
but still return Invalid Syntax, may i know is it possible to post data to graphQL API
in Mule 4? what's syntax error in below code?

%dw 2.0
output application/json
---
{
query: "query{
    test (first: 10, status: \"ACTIVE\" ) {
        edges {
            node {
                id
                ref
                type
                status
                attributes {
                    name
                    value
                    type
                }
            }
        }
    }"
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

硪扪都還晓 2025-01-31 16:26:46

是的,可以将数据发布到mule 4中的GraphQl API。您遇到的错误可能是因为您在查询中缺少闭合括号。尝试一下

%dw 2.0
output application/json
---
{
    query: "query{
        test (first: 10, status: \"ACTIVE\" ) {
            edges {
                node {
                    id
                    ref
                    type
                    status
                    attributes {
                        name
                        value
                        type
                    }
                }
            }
        }
    }"
}

Yes it is possible to post data to GraphQL API in Mule 4. The Error that you are getting is probably because you are missing a closing parenthesis in your query. Try this

%dw 2.0
output application/json
---
{
    query: "query{
        test (first: 10, status: \"ACTIVE\" ) {
            edges {
                node {
                    id
                    ref
                    type
                    status
                    attributes {
                        name
                        value
                        type
                    }
                }
            }
        }
    }"
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文