Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fetchData() {
API.query(/* GraphQL */`
person(f:me) {
id, name, role, emailAddress, rank, status
position {
id, name, type, isApprover
organization { id, shortName , allDescendantOrgs { id }}
}
}
adminSettings(f:getAll) {
key, value
}
organizationList(f:getTopLevelOrgs, type: ADVISOR_ORG) {
list { id, shortName }
}
`).then(data => {
let queries = this.getQueriesForUser(currentUser)
//Run those four queries
let graphQL = /* GraphQL */`
tileOne: reportList(f:search, query:$queryOne) { totalCount},
tileTwo: reportList(f:search, query: $queryTwo) { totalCount},
tileThree: reportList(f:search, query: $queryThree) { totalCount },
tileFour: reportList(f:search, query: $queryFour) { totalCount },
savedSearches: savedSearchs(f:mine) {id, name, objectType, query}`
let variables = {
queryOne: queries[0].query,
queryTwo: queries[1].query,
queryThree: queries[2].query,
queryFour: queries[3].query
}
API.query(graphQL, variables,
"($queryOne: ReportSearchQuery, $queryTwo: ReportSearchQuery, $queryThree: ReportSearchQuery, $queryFour: ReportSearchQuery)")
.then(data => {
let selectedSearch = data.savedSearches && data.savedSearches.length > 0 ? data.savedSearches[0] : null
this.setState({
tileCounts: [data.tileOne.totalCount, data.tileTwo.totalCount, data.tileThree.totalCount, data.tileFour.totalCount],
savedSearches: data.savedSearches,
selectedSearch: selectedSearch
})
})
}
fetchData(props) {
API.query(/* GraphQL */`
organization(id:${props.params.id}) {
id, shortName, longName, type,
parentOrg { id, shortName, longName }
approvalSteps { id, name
approvers { id, name, person { id, name}}
},
poams { id, shortName, longName}
}
`).then(data => {
this.setState({
organization: new Organization(data.organization),
originalOrganization: new Organization(data.organization)
})
})
}
fetchData(props) {
if (props.location.query.parentOrgId) {
API.query(/* GraphQL */`
organization(id: ${props.location.query.parentOrgId}) {
id, shortName, longName, type
}
`).then(data => {
let {organization, originalOrganization} = this.state
organization.parentOrg = new Organization(data.organization)
organization.type = organization.parentOrg.type
originalOrganization.parentOrg = new Organization(data.organization)
originalOrganization.type = originalOrganization.parentOrg.type
this.setState({organization, originalOrganization})
})
}
}
fetchData(props) {
API.query(/* GraphQL */`
adminSettings(f:getAll) { key, value }
`).then(data => {
let settings = {}
data.adminSettings.forEach(setting => settings[setting.key] = setting.value)
this.setState({settings})
})
}
fetchData(props) {
API.query(/* GraphQL */`
poam(id:${props.params.id}) {
id, shortName, longName, status,
responsibleOrg {id,shortName, longName}
}
`).then(data => {
this.setState({poam: new Poam(data.poam), originalPoam: new Poam(data.poam)})
})
}
fetchData(props) {
API.query(/* GraphQL */`
report(id:${props.params.id}) {
id, intent, engagementDate, atmosphere, atmosphereDetails
keyOutcomes, reportText, nextSteps, cancelledReason
state
location { id, name }
author {
id, name, rank,
position {
organization {
shortName, longName
approvalSteps {
id, name,
approvers {
id, name,
fetchData(props) {
API.query(/*GraphQL*/ `
person(id:${props.params.id}) {
id,
name, rank, role, emailAddress, phoneNumber, status
biography, country, gender, endOfTourDate,
position {
id, name
}
}
`).then(data => {
if (data.person.endOfTourDate) {
data.person.endOfTourDate = moment(data.person.endOfTourDate).format()
}
this.setState({person: new Person(data.person), originalPerson: new Person(data.person)})
})
}
run(parts) {
let query = parts.map(p => p.queryString).join(',\n')
let variables = {}
let variableDefs = []
parts.forEach(part => {
part.variables.forEach(variable => {
variables[variable.name] = variable.value
variableDefs.push(`$${variable.name}: ${variable.type}`)
})
})
let variableDef = '(' + variableDefs.join(', ') + ')'
return API.query(query, variables, variableDef)
},