Thread
#prefect-community
    Dexter Antonio

    Dexter Antonio

    6 months ago
    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;
    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
    .
    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?
    Kevin Kho

    Kevin Kho

    6 months ago
    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:
    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)
    Dexter Antonio

    Dexter Antonio

    6 months ago
    great, that is really easy