how can i create a graphql to get all service factsheets based on filters as
tags = “ABC”,
Owning User Group = “Technology” or “Engineering”
thank you in advance.
how can i create a graphql to get all service factsheets based on filters as
tags = “ABC”,
Owning User Group = “Technology” or “Engineering”
thank you in advance.
Hello and welcome!
Further to that, you can experiment and access the GraphQL API documentation through the provided GraphiQL interface (it requires admin access).
Hi
Hi
Try something like this format:
query MyQuery {
allFactSheets(
filter: {facetFilters: :
{facetKey: "FactSheetTypes", operator: OR, keys: :"ITComponent"]},
{facetKey: "category", operator: OR, keys:s"service"]},
{facetKey: "_TAGS_", operator: OR, keys: :"16d475fb-4f2c-4058-928d-3dc57676c5a8"]}
]}
) {
edges {
node {
id
name
}
}
}
}
Hope it helps.
You can use this query to find out all the facetKey values in your workspace:
{
allFactSheets{
filterOptions {
facets {
facetKey
results {
name
key
}
}
}
}
}
Cheers
Hi
I use (as some described in the documentation) the debugging window of Chrome or Edge: Go to inventory, add you filter and in Tabular view select the fields you want to retrieve (I used the tag Retire in my example):
When the result fits your desired outcome press F12, open the debugger send select network
Press refresh in the inventory:
You now see graphql statement in the debugger:
Click on it:
Click ‘view source’:
Select the statement text (json) and copy it into your editor:
{"query":"query allFactSheetsQuery($filter:FilterInput!, $sortings:sSorting]){allFactSheets(first:40,filter:$filter, sort:$sortings){totalCount pageInfo{hasNextPage hasPreviousPage startCursor endCursor}filterOptions{facets{facetKey facetType facetSubType total possibleOperators operator globalFacet results{name key count selected}dateFilter{from to type minDate maxDate}subscriptionFilter{type role{id name}}subFilter{facetFilters{facetKey operator keys dateFilter{from to type}subscriptionFilter{type role{id name}}}fullTextSearch ids}relationFieldsFilterOperator relationFieldsFilter{fieldName values{key selected}}}}}}","variables":{"filter":{"responseOptions":{"maxFacetDepth":5},"facetFilters":F{"facetKey":"FactSheetTypes","operator":"OR","keys":""ITComponent"]},{"facetKey":"category","operator":"OR","keys":""service"]},{"facetKey":"9b18f72d-7da4-4f7f-9c7d-1df95ffa1276","operator":"OR","keys":""a4460b1f-fe8e-4292-b1c2-2f535a2f3ff3"]}]},"sortings":o{"key":"displayName","order":"asc"}]}}
It’s not well formatted (but can be used as is). To use it in the Graphql explorer you have to remove quotation marks where not needed or adjust it to your need in your program source code.
Btw.: Tags are represented by its id, so it differs a bit from
Best regards,
Carsten
On the tags ids (it is not only tags, subscriptions also), you can use the second GraphQL query (facets) to get the ids.
Hi
Try this graphql query to get factsheet through particular tag. This is for update IT component factsheets but you can make changes in it as per ypur requirment.
def update_it_component_alias(component_id, alias, category): mutation = """ mutation ($id: ID!, $patches: ePatch]!) { updateFactSheet(id: $id, patches: $patches) { factSheet { id name ... on ITComponent { alias } } } } """ variables = { "id": component_id, "patches": s { "op": "replace", "path": "/alias", "value": alias }, { "op": "replace", "path": "/description", "value": category } ] } data = {"query": mutation, "variables": variables} response = requests.post(url=request_url, headers=headers, data=json.dumps(data)) response.raise_for_status()
Hi
Hi
I’m not sure if you are aware of this, but there is already a fully-scoped Python module where such queries only take one single line of code without reinventing the wheel:
Let me know in case you have any questions regarding this module.
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.