【问题标题】:Dagster Graphql get all jobs in a RepoDagster Graphql 在回购中获得所有工作
【发布时间】:2022-06-01 03:23:52
【问题描述】:

我希望将 dagster Graphql 用作记录在案的here

我想在 repo 中获取所有作业,我正在使用上述文档中概述的“获取存储库中的作业列表”查询

并得到以下错误

{
  "error": {
    "data": null,
    "errors": [
      {
        "message": "Field \"repositoryOrError\" of type \"RepositoryOrError!\" must have a sub selection.",
        "locations": [
          {
            "line": 2,
            "column": 3
          }
        ]
      },
      {
        "message": "Argument \"repositorySelector\" has invalid value {repositoryLocationName: repositoryLocationName, repositoryName: repositoryName}.\nIn field \"repositoryName\": Expected type \"String\", found repositoryName.\nIn field \"repositoryLocationName\": Expected type \"String\", found repositoryLocationName.",
        "locations": [
          {
            "line": 2,
            "column": 41
          }
        ]
      },
      {
        "message": "Variable \"$repositoryLocationName\" is never used in operation \"JobsQuery\".",
        "locations": [
          {
            "line": 1,
            "column": 17
          }
        ]
      },
      {
        "message": "Variable \"$repositoryName\" is never used in operation \"JobsQuery\".",
        "locations": [
          {
            "line": 1,
            "column": 51
          }
        ]
      }
    ]
  }
}

我在 python 和 GraphQL Playground 都试过这个

有谁知道我可能哪里出错了?

编辑:

添加给出此错误的python代码:

query1 = """query JobsQuery(
  $repositoryLocationName:  String!,
  $repositoryName: String!
) {
  repositoryOrError(
    repositorySelector: {
      repositoryLocationName: repositoryLocationName,
      repositoryName: repositoryName
    }
  ) {
    ... on Repository {
      jobs {
        name
      }
    }
  }
}"""

variables  = {"repositoryLocationName": "eliaapifetcher", "repositoryName": "elia_api_repo"}

url = 'http://localhost:4200/dagster/graphql'

r1 = requests.post(url, json={'query': query1, 'variables': variables})

【问题讨论】:

  • 你好呀!您能否添加一些您尝试过的代码?看起来你可能有一个格式错误的查询,但如果没有看到你的代码就很难说。
  • 我已将 python 代码添加到产生错误的帖子中,我在 graphql 操场上也遇到了同样的错误

标签: graphql dagster


【解决方案1】:

我认为您需要在查询中对变量进行 $-escape,如下所示:

query1 = """query JobsQuery(
  $repositoryLocationName:  String!,
  $repositoryName: String!
) {
  repositoryOrError(
    repositorySelector: {
      repositoryLocationName: $repositoryLocationName,
      repositoryName: $repositoryName
    }
  ) {
    ... on Repository {
      jobs {
        name
      }
    }
  }
}"""

variables  = {"repositoryLocationName": "eliaapifetcher", "repositoryName": "elia_api_repo"}

url = 'http://localhost:4200/dagster/graphql'

r1 = requests.post(url, json={'query': query1, 'variables': variables})

否则它只会将 repositoryLocationNamerepositoryName 解释为文字字符串

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-23
    • 2020-12-11
    • 1970-01-01
    • 1970-01-01
    • 2022-05-19
    • 1970-01-01
    • 1970-01-01
    • 2021-08-25
    相关资源
    最近更新 更多