https://prefect.io logo
a

Aiden Price

08/31/2021, 3:17 AM
Hi everyone! I have a GraphQL question as well. I'm trying to get and set the default parameters for a flow_group, can anyone help me?
I have a
query
like this;
Copy code
query($path: String!) {
  flow {
    id
    name
    flow_group_id
    flow_group {
      id
      name
      default_parameters(path: $path)
    }
  }
}
But I get Interval server errors, "Cannot return null for non-nullable field flow.id." Which I assume means that I've made a mistake in the query.
I'm really just trying to get all the default parameters for the flow group. And I'll later on try and set some of them in a Mutation
And when I try to set default parameters in a Mutation like this one;
Copy code
mutation($flow_group_id: UUID!, $params: JSON!) {
    set_flow_group_default_parameters(
        input: {
            flow_group_id: $flow_group_id,
            parameters: $params
        }
    ) {
        success
        error
    }
}
With parameters like this;
Copy code
{
  "flow_group_id": "e214d16b-ca58-453c-b67f-xxxxxxxxxxxxx",
  "params": "{\"site_timezone\": \"Australia/Queensland\"}"
}
I get an error that says
value is not a valid dict (type=type_error.dict)
k

Kevin Kho

08/31/2021, 4:50 AM
Hey @Aiden Price, what are you trying to do with the path in the first query? Isn’t this enough to get the parameters?
Copy code
query {
  flow {
    id
    name
    flow_group {
      id
      name
      default_parameters
    }
  }
}
Or is it that you want the path specifically?
a

Aiden Price

08/31/2021, 4:53 AM
I tried to just get the default parameters like you suggested but I just get an empty object back for all my flows
{}
when I was expecting that all of them would have at least one
k

Kevin Kho

08/31/2021, 4:54 AM
Ah ok will test this
a

Aiden Price

08/31/2021, 4:55 AM
Thanks
k

Kevin Kho

08/31/2021, 4:56 AM
So I think there’s two things here. First are the default parameters that are set in the code. These can be found under
flow -> parameters
. In the UI though, you can set overrides to these and those will populate
flow_group -> default_parameters
So maybe you’re looking for something like this?
Copy code
query {
  flow (where: {name: {_eq: "docker_example"}}){
    id
    name
    parameters
    flow_group {
      id
      name
      default_parameters
    }
  }
}
And you’ll find them under the parameters block
a

Aiden Price

08/31/2021, 4:59 AM
So the default parameters are under the
flow
not the
flow_group
? because I still get an empty object for the
default_parameters
And I get multiple copies of the
flow
presumably because of all the versions. I assumed that I could change the parameters for the
flow_group
and then I would change the defaults for any new versions.
k

Kevin Kho

08/31/2021, 5:05 AM
Did you set values on this page? These overrides are the one that would apply on the flow group level.
Yes default parameters set in code are under flow. The ones set of the
flow_group
are treated as overrides
a

Aiden Price

08/31/2021, 5:55 AM
Oh okay, thank you for clearing that up. Can you also help with setting them with JSON values in the Mutation? I still get this error;
value is not a valid dict (type=type_error.dict)
when I try to post the mutation.
b

Bouke Krom

08/31/2021, 10:19 AM
Did you try not escaping the quotes in your variables? ie
Copy code
{
  "flow_group_id": "e214d16b-xxxxxxxxxxxxx",
  "params": {
    "site_timezone": "Australia/Queensland"
  }
}
GraphiQL will give you warnings about expecting a JSON but the query might work.
a

Aiden Price

08/31/2021, 10:30 AM
Hey that did work, weird. Thank you @Bouke Krom
b

Bouke Krom

08/31/2021, 10:32 AM
Happy to help! GraphQL takes some getting used to, I know from experience 😉
👍 2
4 Views