How to use the relay-runtime.fetchQuery function in relay-runtime

To help you get started, we’ve selected a few relay-runtime examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github magma / magma / symphony / app / fbcnms-projects / inventory / app / components / EquipmentTypesList.js View on Github external
componentDidMount() {
    // $FlowFixMe (T62907961) Relay flow types
    fetchQuery(RelayEnvironment, equipmentQuery).then(response => {
      this.setState({
        equipmentTypes: response.equipmentTypes.edges.map(x => x.node),
      });
    });
  }
github magma / magma / symphony / app / fbcnms-projects / inventory / app / components / typeahead / ServiceTypeahead.js View on Github external
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 => ({
github episodeyang / ml_logger / ml-dash-client / src / Charts / FileViews.js View on Github external
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})
}
github magma / magma / symphony / app / fbcnms-projects / inventory / app / components / admin / userManagement / UsersSettings.js View on Github external
const fetchAndEditUser = (email, role) => {
    return fetchQuery(RelayEnvironment, userQuery, {
      authID: email,
    }).then(data => editUserInfo(data.user.id, role));
  };
github magma / magma / symphony / app / fbcnms-projects / inventory / app / components / InventoryEntitiesTypeahead.js View on Github external
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,
github berty / berty / client / react-native / app / graphql / queries / DeviceInfos.js View on Github external
fetch: async () =>
    (await fetchQuery(context.environment, query, { t: true })).DeviceInfos,
})
github magma / magma / symphony / app / fbcnms-projects / inventory / app / components / location / LocationAddEditCard.js View on Github external
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),
        },
      );
github magma / magma / symphony / app / fbcnms-projects / inventory / app / components / projects / AddProjectCard.js View on Github external
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);
    }
github magma / magma / symphony / app / fbcnms-projects / inventory / app / components / admin / userManagement / utils / search / UserSearchContext.js View on Github external
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 [];
    }