Managing Resources on a Fact Sheet

Manage fact sheet resources through the GraphQL API.

To store additional information on a fact sheet, you can add the following resources to it: links, files, diagrams, and logos. To learn how to work with resources in the application UI, see Store Resources on Fact Sheets.

📘

Note

In the LeanIX GraphQL API, fact sheet resources are referred to as documents.

Creating a Resource on a Fact Sheet

To create a resource on a fact sheet, use the createDocument mutation. factSheetId and name are required arguments for this mutation. To learn how to get the ID of a fact sheet, see Retrieving Fact Sheets.

In the following example, we add a link to a fact sheet as a resource.

Example mutation for adding a link:

mutation createDocument {
  createDocument(
    factSheetId: "01740698-1ffa-4729-94fa-da6194ebd7cd"
    name: "Website link"
    url: "https://www.leanix.net/"
    description: "Link to the LeanIX website"
  ) {
    id
    name
    url
    description
    factSheetId
  }
}

Example response:

{
  "data": {
    "createDocument": {
      "id": "fc87eb51-0f2e-4b77-9df3-f6325b6836fd",
      "name": "Website link",
      "url": "https://www.leanix.net/",
      "description": "Link to the LeanIX website",
      "factSheetId": "01740698-1ffa-4729-94fa-da6194ebd7cd"
    }
  }
}

To be able to upload files and logos as resources to a fact sheet, activate the Uploading Files on Fact Sheets feature in Optional Features in the administration area. If this feature is deactivated, uploading files and logos through the GraphQL API is not possible.

To create resources of the File and Logo types using the createDocument mutation, provide the GraphQL request and file stream as form data. To upload a file to a fact sheet as a resource, use the GraphQL endpoint for file uploads:

https://{SUBDOMAIN}.leanix.net/services/pathfinder/v1/graphql/upload

📘

Note

For a Logo resource, the documentType argument is required and should be set to logo. You can only upload one logo to a fact sheet.

For File resources, the documentType argument is optional. You can upload multiple files to a fact sheet.

Example mutation for uploading a logo:

mutation createDocument {
  createDocument(
    factSheetId: "01740698-1ffa-4729-94fa-da6194ebd7cd"
    name: "leanix.png"
    documentType: "logo"
  ) {
    id
    name
    url
    factSheetId
  }
}

Example response:

{
  "data": {
    "createDocument": {
      "id": "ec87eb51-0f2e-4b77-9df3-f6325b6836fd",
      "name": "leanix.png",
      "url": "<<storage location of the logo>>",
      "factSheetId": "01740698-1ffa-4729-94fa-da6194ebd7cd"
    }
  }
}

Retrieving Fact Sheet Resources

To retrieve resources stored on a specific fact sheet, use the factSheet query. The fact sheet id is a required argument for this query.

Example query:

{
  factSheet(id: "4d121f64-116b-4ccc-a292-eb4e4f8d1b24") {
    id
    name
    documents {
      edges {
        node {
          origin
          url
          name
          id
        }
      }
    }
  }
}

Example response:

{
  "data": {
    "factSheet": {
      "id": "4d121f64-116b-4ccc-a292-eb4e4f8d1b24",
      "name": "AC Management Cloud",
      "documents": {
        "edges": [
          {
            "node": {
              "origin": "CUSTOM_LINK",
              "url": "https://www.leanix.net/",
              "name": "Website link",
              "id": "22b9ed8f-5dea-48e8-b9c4-d7db97a811e4"
            }
          }
        ]
      }
    }
  }
}

Updating a Resource on a Fact Sheet

To update a resource on a fact sheet, use the updateDocument mutation. id is a required argument for this mutation. To get the resource ID, retrieve all fact sheet resources and copy the id from the response. To learn more, see Retrieving Fact Sheet Resources.

To update specific fields on a resource, apply patch operations. In the example, we change the link URL using the replace patch operation.

Example mutation:

mutation updateDocument($patches: [Patch]!) {
  updateDocument(
    id: "22b9ed8f-5dea-48e8-b9c4-d7db97a811e4"
    patches: $patches
  ) {
    id
    name
    url
  }
}

Variables:

{
  "patches": [
    {
      "op": "replace",
      "path": "/url",
      "value": "https://www.leanix.net/de/"
    }
  ]
}

Example response:

{
  "data": {
    "updateDocument": {
      "id": "22b9ed8f-5dea-48e8-b9c4-d7db97a811e4",
      "name": "Website link",
      "url": "https://www.leanix.net/de/"
    }
  }
}

Deleting a Resource from a Fact Sheet

To delete a resource from a fact sheet, use the deleteDocument mutation. id is a required argument for this mutation. To get the resource ID, retrieve all fact sheet resources and copy the id from the response. To learn more, see Retrieving Fact Sheet Resources.

Example mutation:

mutation {
  deleteDocument(id: "a1904f80-f9b8-4fd6-848c-bad1f55192d2") {
    name
  }
}

Example response:

{
  "data": {
    "deleteDocument": null
  }
}