Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
componentDidMount() {
// $FlowFixMe (T62907961) Relay flow types
fetchQuery(RelayEnvironment, equipmentQuery).then(response => {
this.setState({
equipmentTypes: response.equipmentTypes.edges.map(x => x.node),
});
});
}
fetchNewServiceSuggestions = (searchTerm: string) => {
fetchQuery(RelayEnvironment, serviceSearchQuery, {
filters: [
{
filterType: 'SERVICE_INST_NAME',
operator: 'CONTAINS',
stringValue: searchTerm,
},
],
limit: 1000,
}).then(response => {
if (!response) {
return;
}
this.setState({
serviceSuggestions: response.services.edges
.map(edge => edge.node)
.map(p => ({
export function fetchTextFile(path) {
let id = toGlobalId("File", path);
return fetchQuery(modernEnvironment, graphql`
query FileViewsTextFileQuery ($id: ID!) {
node (id: $id) {
id
... on File { text }
}
}`, {id})
}
const fetchAndEditUser = (email, role) => {
return fetchQuery(RelayEnvironment, userQuery, {
authID: email,
}).then(data => editUserInfo(data.user.id, role));
};
fetchNewSuggestions(searchTerm: string) {
const {classes} = this.props;
fetchQuery(
RelayEnvironment,
inventoryEntitiesTypeaheadQuery,
{
name: searchTerm,
},
).then(response => {
if (!response || !response.searchForNode) {
return;
}
const mapToSuggestion = (node): ?Suggestion => {
if (node.__typename === 'Equipment') {
return {
entityId: node.id,
entityType: 'equipment',
name: node.name,
fetch: async () =>
(await fetchQuery(context.environment, query, { t: true })).DeviceInfos,
})
async getEditingLocation(): any {
let location = null;
let locationType = null;
if (this.props.editingLocationId) {
const response = await fetchQuery(
RelayEnvironment,
locationAddEditCardQuery,
{
locationId: this.props.editingLocationId,
},
);
location = response.location;
locationType = location.locationType;
} else {
const response = await fetchQuery(
RelayEnvironment,
locationAddEditCard__locationTypeQuery,
{
locationTypeId: nullthrows(this.props.type?.id),
},
);
async getProject(): Promise {
const response = await fetchQuery(
RelayEnvironment,
addProjectCard__projectTypeQuery,
{
projectTypeId: this.props.projectTypeId,
},
);
const projectType = response.projectType;
let initialProps = [];
if (projectType.properties) {
initialProps = projectType.properties
.filter(propertyType => !propertyType.isDeleted)
.map(propType => getInitialPropertyFromType(propType));
initialProps = initialProps.sort(sortPropertiesByIndex);
}
const searchCallback = (searchTerm: string) =>
fetchQuery(RelayEnvironment, userSearchQuery, {
filters: [
{
filterType: 'USER_NAME',
operator: 'CONTAINS',
stringValue: searchTerm,
},
{
filterType: 'USER_STATUS',
operator: 'IS',
statusValue: USER_STATUSES.ACTIVE.key,
},
],
}).then(response => {
if (response?.users == null) {
return [];
}