Skip to content

Instantly share code, notes, and snippets.

@loloDawit
Created November 19, 2021 01:45
Show Gist options
  • Select an option

  • Save loloDawit/2b17453b15458eef2fb130155b355d23 to your computer and use it in GitHub Desktop.

Select an option

Save loloDawit/2b17453b15458eef2fb130155b355d23 to your computer and use it in GitHub Desktop.
queries.js
"use strict";
/**
* account Uses tagName to get account specific info
* @param {*} tagName
* @returns JSON with error or success
*/
const account = (tagName) => {
return JSON.stringify({
query: `{
actor {
entitySearch(queryBuilder: {type: DASHBOARD, tags: {key: "account", value: "${tagName}"}}, sortBy: NAME) {
results {
entities {
... on DashboardEntityOutline {
guid
name
accountId
owner {
email
}
permissions
updatedAt
}
}
}
}
}
}`,
variables: {}
});
};
/**
* getDashboardInfo Uses guid to get a dashboard info
* @param {*} guid
* @returns JSON with error or success
*/
const getDashboardInfo = (guid) => {
return JSON.stringify({
query: `{
actor {
entity(guid: "${guid}") {
... on DashboardEntity {
guid
accountId
name
createdAt
updatedAt
permissions
description
owner {
email
userId
}
pages {
guid
name
createdAt
updatedAt
description
owner {
email
userId
}
widgets {
id
visualization {
id
}
title
layout {
row
column
height
width
}
rawConfiguration
linkedEntities {
guid
}
}
}
}
}
}
}`,
variables: {}
});
};
/**
* unDelete Uses guid to unDelete a dashboard
* @param {*} guid
* @returns JSON with error or success
*/
const unDelete = (guid) => {
return JSON.stringify({
query: `mutation {
dashboardUndelete(guid: "${guid}") {
errors {
description
type
}
}
}`,
variables: {}
});
};
module.exports = {account, getDashboardInfo, unDelete};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment