https://prefect.io logo
Title
n

Nico Neumann

04/11/2022, 2:39 PM
Hey! I try to interact with the GraphQL api and I want to set the default parameters for a flow group. What is the right way to pass the parameters (as dict/json) into the query?
:discourse: 1
I have a query like this:
mutation {
  set_flow_group_default_parameters(
    input: {
      flow_group_id: "...", 
      parameters: {"name": "test"}
    } 
  ) {
    success
  }
}
But I get
Syntax Error: Expected Name, found String "name".
When I remove the quotes from
name
the query runs but I get
"Expected type JSON!, found {name: \"test\"}; 'ObjectValueNode' object has no attribute 'value'"
I found this test in prefect/server:
success = await api.flow_groups.set_flow_group_default_parameters(flow_group_id=flow_group_id, parameters={"meep": "morp", "bleep": "blorp"})
k

Kevin Kho

04/11/2022, 2:59 PM
Looking into this
I find even with the warning it still works:
as a python script
query = """
mutation SetDefaultParams($input: set_flow_group_default_parameters_input!){
  set_flow_group_default_parameters(input: $input) {
    success
  }
}
"""
from prefect.client import Client 
client = Client()
_input = {"input": 
      {
        "flow_group_id": "7fb20810-cd37-41cf-9b04-218c284f6db5", 
        "parameters": {"x": "test test test"}
      }
} 

print(client.graphql(query, variables=_input))
😍 1
n

Nico Neumann

04/11/2022, 3:48 PM
@Kevin Kho Thanks a lot, works great!