Filtering Fact Sheets

Example queries for filtering fact sheets through the GraphQL API.

The following examples show how to apply facet filters when using the allFactSheets query to retrieve fact sheets. To learn how filtering in GraphQL works and how to retrieve facet keys, see Filtering in GraphQL.

Filtering Fact Sheets by Type

To filter fact sheets of specific types, use the FactSheetTypes facet filter. In the example, we retrieve Application, ITComponent, and BusinessCapability fact sheets.

Example query:

query retrieveFactSheetsByType($filter: FilterInput!) {
  allFactSheets(filter: $filter) {
    totalCount
    edges {
      node {
        id
        displayName
        type
      }
    }
  }
}

Variables:

{
  "filter": {
    "facetFilters": [
      {
        "facetKey": "FactSheetTypes",
        "operator": "OR",
        "keys": [
          "Application",
          "ITComponent",
          "BusinessCapability"
        ]
      }
    ]
  }
}

Example response:

{
  "data": {
    "allFactSheets": {
      "totalCount": 291,
      "edges": [
        {
          "node": {
            "id": "3c86fe91-df46-4fde-8191-6c67253ca91a",
            "displayName": "Corporate Services",
            "type": "BusinessCapability"
          }
        },
        {
          "node": {
            "id": "b5e0fc18-bef0-414d-a38a-3409a2f8c01f",
            "displayName": "Corporate Services / Fleet Management",
            "type": "BusinessCapability"
          }
        },
        ...
        {
          "node": {
            "id": "58f554bc-b8f2-487e-b598-df27b4a8e870",
            "displayName": "AC Management",
            "type": "Application"
          }
        },
        {
          "node": {
            "id": "91a18208-aade-4a64-ae58-11a6a307a26e",
            "displayName": "AC Management Cloud",
            "type": "Application"
          }
        },
        ...
        {
          "node": {
            "id": "645a6128-6f47-45da-bd88-51ed548c6c44",
            "displayName": "Microsoft .NET Framework 1.0 Service Pack 3",
            "type": "ITComponent"
          }
        },
        {
          "node": {
            "id": "5ca2c6e0-7414-4887-9dee-5d0f388cf89f",
            "displayName": "Microsoft .NET Framework 1.1",
            "type": "ITComponent"
          }
        },
        ...
      ]
    }
  }
}

For a single fact sheet type, you can pass the factSheetType argument in the allFactSheets query.

Example query:

{
  allFactSheets(factSheetType: Application) {
    totalCount
    edges {
      node {
        id
        name
        type
      }
    }
  }
}

Example response:

{
  "data": {
    "allFactSheets": {
      "totalCount": 50,
      "edges": [
        {
          "node": {
            "id": "28fe4aa2-6e46-41a1-a131-72afb3acf256",
            "name": "AC Management",
            "type": "Application"
          }
        },
        {
          "node": {
            "id": "2efa37b5-18aa-48d8-9d70-1328c0d856d7",
            "name": "AC Management Cloud",
            "type": "Application"
          }
        },
        ...
      ]
    }
  }
}

Filtering Fact Sheets by Type and Technical Fit

To filter fact sheets by type and technical fit, use the following facet keys:

  • FactSheetTypes: Filter for fact sheet types.
  • technicalSuitability: Filter for the technical fit attribute.

In the example, we retrieve Application fact sheets with the unreasonable technical fit.

Example query:

query TechnicalFit($filter: FilterInput!) {
  allFactSheets(filter: $filter) {
    edges {
      node {
        ... on Application {
          id
          displayName
          technicalSuitability
        }
      }
    }
  }
}

Variables:

{
  "filter": {
    "facetFilters": [
      {
        "facetKey": "FactSheetTypes",
        "operator": "OR",
        "keys": [
          "Application"
        ]
      },
      {
        "facetKey": "technicalSuitability",
        "operator": "OR",
        "keys": [
          "unreasonable"
        ]
      }
    ]
  }
}

Example response:

{
  "data": {
    "allFactSheets": {
      "edges": [
        {
          "node": {
            "id": "01740698-1ffa-4729-94fa-da6194ebd7cd",
            "displayName": "AC Management",
            "technicalSuitability": "unreasonable"
          }
        },
        {
          "node": {
            "id": "2efa37b5-18aa-48d8-9d70-1328c0d856d7",
            "displayName": "AC Management Cloud",
            "technicalSuitability": "unreasonable"
          }
        }
      ]
    }
  }
}

Filtering Fact Sheets by Type and Lifecycle Phase

To filter fact sheets by type and lifecycle phase, use the following facet keys:

  • FactSheetTypes: Filter for fact sheet types.
  • lifecycle: Filter for the lifecycle phase attribute. Adding dateFilter is required for this facet.

In the example, we retrieve Application fact sheets in the phaseIn phase with start dates within the specified time frame (between 2023 and 2029).

Example query:

query filterLifeCycle($filter: FilterInput!) {
  allFactSheets(filter: $filter) {
    edges {
      node {
        ... on Application {
          id
          name
          ApplicationLifecycle: lifecycle {
            asString
            phases {
              startDate
            }
          }
        }
      }
    }
  }
}

Variables:

{
  "filter": {
    "facetFilters": [
      {
        "facetKey": "FactSheetTypes",
        "operator": "OR",
        "keys": [
          "Application"
        ]
      },
      {
        "facetKey": "lifecycle",
        "operator": "OR",
        "keys": [
          "phaseIn"
        ],
        "dateFilter": {
          "type": "RANGE",
          "from": "2023-01-01",
          "to": "2029-12-31"
        }
      }
    ]
  }
}

Example response:

{
  "data": {
    "allFactSheets": {
      "edges": [
        {
          "node": {
            "id": "2efa37b5-18aa-48d8-9d70-1328c0d856d7",
            "name": "AC Management Cloud",
            "ApplicationLifecycle": {
              "asString": "phaseIn",
              "phases": [
                {
                  "startDate": "2023-11-01"
                }
              ]
            }
          }
        }
      ]
    }
  }
}

Filtering Fact Sheets by Type and Tags

To filter fact sheets by type and assigned tags, use the following facet keys:

  • FactSheetTypes: Filter for fact sheet types.
  • _TAGS_: Filter for tags assigned to fact sheets. You can use this facet key to filter tags from any tag group, including those that don't belong to any group. In the keys array, pass the tag IDs, not names. To retrieve tag IDs, use the allTags query.
    • To apply a filter for tags from a specific tag group, pass the tag group ID in the facet key instead of _TAGS_. To retrieve tag group IDs, use the allTagGroups query.

In the example, we filter Platform fact sheets with both Production and Beta tags assigned.

To sort the results by the most recently updated fact sheets, use the sortings argument with the updatedAt key and desc value.

Example query:

query platformTag($filter: FilterInput!, $sortings: [Sorting]) {
  allFactSheets(filter: $filter, sort: $sortings) {
    totalCount
    edges {
      node {
        ... on Platform {
          id
          displayName
          type
          updatedAt
          tags {
            id
            name
          }
        }
      }
    }
  }
}

Variables:

{
  "filter": {
    "facetFilters": [
      {
        "facetKey": "FactSheetTypes",
        "operator": "OR",
        "keys": [
          "Platform"
        ]
      },
      {
        "facetKey": "_TAGS_",
        "operator": "AND",
        "keys": [
          "6c8d1073-0724-4582-97bd-c972e85be0cb",
          "1c9c71b0-db60-453e-b607-05471c4f839a"
        ]
      }
    ]
  },
  "sortings": [
    {
      "key": "updatedAt",
      "order": "desc"
    }
  ]
}

Example response:

{
  "data": {
    "allFactSheets": {
      "totalCount": 2,
      "edges": [
        {
          "node": {
            "id": "dc78b30e-8b16-4a60-a1b0-837a1663d6d8",
            "displayName": "Design Platform",
            "type": "Platform",
            "updatedAt": "2024-03-25T14:42:47.803291477Z",
            "tags": [
              {
                "id": "6c8d1073-0724-4582-97bd-c972e85be0cb",
                "name": "Beta"
              },
              {
                "id": "1c9c71b0-db60-453e-b607-05471c4f839a",
                "name": "Production"
              }
            ]
          }
        },
        {
          "node": {
            "id": "07fac0d6-76bc-4e46-88c0-f4a1596172cc",
            "displayName": "BI Platform",
            "type": "Platform",
            "updatedAt": "2024-03-25T14:40:32.422964977Z",
            "tags": [
              {
                "id": "1c9c71b0-db60-453e-b607-05471c4f839a",
                "name": "Production"
              },
              {
                "id": "6c8d1073-0724-4582-97bd-c972e85be0cb",
                "name": "Beta"
              }
            ]
          }
        }
      ]
    }
  }
}

Filtering Fact Sheets by External ID

You can filter fact sheets with a specific external ID. In the example, we filter fact sheets where the externalId is set to 1234.

Example query:

{
  allFactSheets(filter: {externalIds: ["externalId/1234"]}) {
    totalCount
    edges {
      node {
        id
        name
        ... on Application {
          externalId {
            externalId
          }
        }
      }
    }
  }
}

Example response:

{
  "data": {
    "allFactSheets": {
      "totalCount": 1,
      "edges": [
        {
          "node": {
            "id": "28fe4aa2-6e46-41a1-a131-72afb3acf256",
            "name": "AC Management",
            "externalId": {
              "externalId": "1234"
            }
          }
        }
      ]
    }
  }
}

Filtering Archived Fact Sheets

To filter archived fact sheets, use the TrashBin facet key.

Example query:

query allFactSheetsQuery($filter: FilterInput!) {
  allFactSheets(filter: $filter) {
    edges {
      node {
        id
        name
        type
        status
      }
    }
  }
}

Variables:

{
  "filter": {
    "responseOptions": {
      "maxFacetDepth": 5
    },
    "facetFilters": [
      {
        "facetKey": "TrashBin",
        "operator": "OR",
        "keys": [
          "archived"
        ]
      }
    ]
  }
}

Example response:

{
  "data": {
    "allFactSheets": {
      "edges": [
        {
          "node": {
            "id": "65e5f779-b7f0-4a1f-9c88-9f0e3ae9bed9",
            "name": "Application Hosting",
            "type": "ITComponent",
            "status": "ARCHIVED"
          }
        }
      ]
    }
  }
}

Filtering Fact Sheets by Fields on Relations

In the following example, we filter application fact sheets that support specific business capabilities. The support type is leading.

Use the relApplicationToBusinessCapability facet key and specify the IDs of business capability fact sheets in the keys array. To return only the relations that match the applied relation field filters, set the relationFieldsFilterOperator parameter to INCLUSIVE.

Example query:

query filterFactSheets($filter: FilterInput!) {
  allFactSheets(filter: $filter) {
    totalCount
    edges {
      node {
        id
        displayName
        type
        ... on Application {
          relApplicationToBusinessCapability {
            edges {
              node {
                type
                supportType
                factSheet {
                  id
                  name
                }
              }
            }
          }
        }
      }
    }
  }
}

Variables:

{
  "filter": {
    "facetFilters": [
      {
        "facetKey": "FactSheetTypes",
        "operator": "OR",
        "keys": [
          "Application"
        ]
      },
      {
        "facetKey": "relApplicationToBusinessCapability",
        "operator": "OR",
        "keys": [
          "5634544d-4cd3-4533-b190-3f947a99e752",
          "0c53c875-feab-4a87-9006-c0b3191aa65f"
        ],
        "relationFieldsFilterOperator": "INCLUSIVE",
        "relationFieldsFilter": [
          {
            "fieldName": "supportType",
            "values": [
              "leading"
            ]
          }
        ]
      }
    ]
  }
}

Example response:

{
  "data": {
    "allFactSheets": {
      "totalCount": 18,
      "edges": [
        {
          "node": {
            "id": "01740698-1ffa-4729-94fa-da6194ebd7cd",
            "displayName": "AC Management",
            "type": "Application",
            "relApplicationToBusinessCapability": {
              "edges": [
                {
                  "node": {
                    "type": "RelApplicationToBusinessCapability",
                    "supportType": "leading",
                    "factSheet": {
                      "id": "5634544d-4cd3-4533-b190-3f947a99e752",
                      "name": "Customer Relationship"
                    }
                  }
                }
              ]
            }
          }
        }
        ...
      ]
    }
  }
}

Filtering Fact Sheets by Subscriptions

To filter fact sheets by subscriptions, use the Subscriptions facet key with the allFactSheets query. To learn more about subscriptions, refer to:

In the following example, we filter fact sheets by user ID, subscription type, and subscription role. We aim to retrieve fact sheets where a specific user is subscribed as ACCOUNTABLE (subscription type) and Solution Architect (custom subscription role).

Subscription types are predefined, with possible values of ACCOUNTABLE, RESPONSIBLE, or OBSERVER. Workspace admins define subscription roles, which are associated with unique IDs. To get the IDs of subscription roles, use the allSubscriptionRoles query.

Example query:

query getSubscriptionRoles {
  allSubscriptionRoles {
    edges {
      node {
        id
        name
      }
    }
  }
}

Example response:

{
  "data": {
    "allSubscriptionRoles": {
      "edges": [
        {
          "node": {
            "id": "8d1aab90-4d86-43e5-9a75-bafccee81732",
            "name": "Data Architect"
          }
        },
        {
          "node": {
            "id": "a523b819-208c-49ef-a0c6-8d8b84464f6e",
            "name": "Solution Architect"
          }
        }
      ]
    }
  }
}

To filter fact sheets that a specific user is subscribed to, pass the user id in the keys array. You can provide multiple user IDs.

  • To get user IDs, retrieve all workspace users by making a GET request to the following endpoint on the MTM REST API. For the endpoint schema, visit the API documentation.

    https://{SUBDOMAIN}.leanix.net/services/mtm/v1/workspaces/{id}/users
    
  • To find your user ID, go to the API Tokens section in the admin area and look for the UserId value.

In the example, we use the FactSheetTypes facet key to return fact sheets of the application type.

Example query:

query retrieveFactSheetsBySubscriber($filter: FilterInput!) {
  allFactSheets(filter: $filter) {
    totalCount
    edges {
      node {
        id
        displayName
        type
      }
    }
  }
}

Variables:

{
  "filter": {
    "facetFilters": [
      {
        "facetKey": "FactSheetTypes",
        "operator": "OR",
        "keys": [
          "Application"
        ]
      },
      {
        "facetKey": "Subscriptions",
        "operator": "OR",
        "keys": [
          "87678c21-98a2-9567-acaa-fc66ff2b9d56"
        ],
        "subscriptionFilter": {
          "type": "ACCOUNTABLE",
          "roleId": "a523b819-208c-49ef-a0c6-8d8b84464f6e"
        }
      }
    ]
  }
}

Example response:

{
  "data": {
    "allFactSheets": {
      "totalCount": 2,
      "edges": [
        {
          "node": {
            "id": "01740698-1ffa-4729-94fa-da6194ebd7cd",
            "displayName": "AC Management",
            "type": "Application"
          }
        },
        {
          "node": {
            "id": "4d121f64-116b-4ccc-a292-eb4e4f8d1b24",
            "displayName": "AC Management Cloud",
            "type": "Application"
          }
        }
      ]
    }
  }
}