I’m having trouble using python’s `client.graphql`...
# prefect-community
d
I’m having trouble using python’s
client.graphql
. This is the graphql query that I want to use. It works on the prefect cloud’s interactive api;
Copy code
query {
  flow(where: {name: {_eq: "autoscorer"}, version:{_eq:10}}) {
    id
    name
    version
    tasks{
      name
      id
    }
  }}
This is my attempt to do it with the
client.graphql
.
Copy code
client.graphql(
{
    'query': {
        'flow(where: {name: {_eq: "autoscorer"}, version:{_eq:10}})': {
            #'id',
            #'name',
            #'version',
            'tasks': {'task_runs': {'id', 'name'}},
        },
    }

})
This works, but if I uncomment the commented fields (e.g.
id
,) I get a syntax error. What is the proper syntax to indicate a root field? Is there any documentation how to use this API in more detail? Is it based off of a common Python GraphQL library?
k
It’s just a post request under the good with utilities for format. I think this is not what you want but you can stick it in like this:
Copy code
from prefect.client import Client 
client = Client()
f = client.graphql(
"""
query {
  flow(where: {name: {_eq: "autoscorer"}, version:{_eq:10}}) {
    id
    name
    version
    tasks{
      name
      id
    }
  }}
"""
)
print(f)
🙌 1
d
great, that is really easy