Skip to main content
Solved

GraphQL query problem

  • September 25, 2024
  • 2 replies
  • 0 views

Forum|alt.badge.img

I'm trying to use GQL to extract detail about our event policies, as the API give very little detail.
And as we have a SL hosted system, DB access is only available to us via the Web UI. 

I've been building the query up, but I'm getting lost on the eventPolicySuppressions.
Here's the code:

query Event_Policies { eventPolicy(id:4075) { id name editedBy {id user} dateEdited severity { id name } enabled source {name} regularExpression1 regularExpression2 regularExpressionSearch autoClearedEvents { id name editedBy {user} } eventPolicySuppressions { entity {__typename}} } }

I only seem to be able to get the entity {_typename} (which is "device") or the entityType ("entityType": "device") as a result. There don't appear to be any other options being offered from the UI suggestions.

Does anyone know how I can get the eventPolicySuppressions device or device groups information?

Thanks,
Richard

 

Best answer by chris_thornton

Hi Richard,

You need to use an inline fragment to get more details. You can do something like the below to get more of what you want for each type, device or devicegroup, and add additional fields from there. Hope that helps!

query Event_Policies { eventPolicy(id: 4075) { id name editedBy { id user } dateEdited severity { id name } enabled source { name } regularExpression1 regularExpression2 regularExpressionSearch autoClearedEvents { id name editedBy { user } } eventPolicySuppressions { entity { __typename ... on DeviceGroup { groups { id } } ... on Device { id } } } } }

 

2 replies

Forum|alt.badge.img

Hi Richard,

You need to use an inline fragment to get more details. You can do something like the below to get more of what you want for each type, device or devicegroup, and add additional fields from there. Hope that helps!

query Event_Policies { eventPolicy(id: 4075) { id name editedBy { id user } dateEdited severity { id name } enabled source { name } regularExpression1 regularExpression2 regularExpressionSearch autoClearedEvents { id name editedBy { user } } eventPolicySuppressions { entity { __typename ... on DeviceGroup { groups { id } } ... on Device { id } } } } }

 


Forum|alt.badge.img
  • Author
  • Contributor
  • September 26, 2024

Hi Chris,

Perfect, thank you sir!