如何在python中的graphql查询中修复“(VAR_SIGN)上的解析错误”

Vin*_*eri 5 python graphql

我在使用 python 进行 GraphQL 查询时遇到了问题。它表示无法解析查询中确定变量的信号 $。

错误信息:

{"errors":[{"message":"[3, 3] 处的 \"$\" (VAR_SIGN) 解析错误","locations":[{"line":3,"column":3}] }]}

在这种请求中还有其他方法可以使用变量吗?

这是我的查询,我没有粘贴片段,因为我认为这不是问题

    query ApplicationIndexQuery(
  $status: Boolean!
  $page: Int
  $perPage: Int
  $filters: ApplicationFilter
  $sort: String
) {
  allOpportunityApplication(page: $page, per_page: $perPage, filters: $filters, sort: $sort) {
    ...ApplicationList_list
  }
}

variables = {

    "status": True,
    "page": 1,
    "perPage": 517,
    "filters": {
        "date_realized": {
            "from": "2018-12-01",
            "to": "2019-03-31"
        },
        "person_home_mc": 1535,
        "programmes": 5
    }
Run Code Online (Sandbox Code Playgroud)

小智 6

query应该位于顶层,但在您的示例中似乎它被括在大括号中。参见下文: https: //github.com/apollographql/graphql-tag/issues/180#issuecomment-386540792