0

I am looking to use the dagster Graphql as a documented here

I want to get all jobs in a repo, I am using the "Get a list of jobs within a repository" query outlined in the above documentation

And Get the following error

{
  "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
          }
        ]
      }
    ]
  }
}

I have tried this in both python and the GraphQL Playground

Does anyone have an idea where I might be going wrong?

edit:

Adding the python code that gives this error:

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})
DavidMul
  • 71
  • 4
  • Hi there! Would you be able to add some of the code that you've tried? It seems like you might have a malformed query but it's tough to say without seeing your code. – zyd May 27 '22 at 15:22
  • I have added the python code to the post that produces the error, I also get the same error in the graphql playground – DavidMul May 30 '22 at 05:53

1 Answers1

0

I think you need to $-escape your variables in your query, like this:

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})

otherwise it'll just interpret repositoryLocationName and repositoryName as literal strings

zyd
  • 833
  • 7
  • 16