How to use the react-relay/classic.Store function in react-relay

To help you get started, weโ€™ve selected a few react-relay 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 meedan / check-web / src / app / components / memebuster / MemebusterComponent.js View on Github external
const onFailure = (transaction) => {
      const error = transaction.getError();
      // eslint-disable-next-line no-console
      console.error(`Error performing Memebuster mutation: ${error}`);
      this.setState({ pending: false });
    };

    const onSuccess = () => {
      this.setState({ pending: false });
    };

    const annotation = this.getLastSaveAnnotation();

    if (!annotation) {
      Relay.Store.commitUpdate(
        new CreateMemebusterMutation({
          image: imageFile,
          parent_type: 'project_media',
          annotator: this.getContext().currentUser,
          annotated: this.props.media,
          annotation: {
            action,
            fields,
            annotated_type: 'ProjectMedia',
            annotated_id: this.props.media.dbid,
          },
        }),
        { onFailure, onSuccess },
      );
    } else {
      Relay.Store.commitUpdate(
github buildkite / frontend / app / components / pipeline / teams / Index / row.js View on Github external
handleAccessLevelChange = (accessLevel) => {
    this.setState({ savingNewAccessLevel: accessLevel });

    const mutation = new TeamPipelineUpdateMutation({
      teamPipeline: this.props.teamPipeline,
      accessLevel: accessLevel
    });

    Relay.Store.commitUpdate(mutation, {
      onSuccess: () => {
        // Hide the saving spinner
        this.setState({ savingNewAccessLevel: null });
      },
      onFailure: (transaction) => {
        // Hide the saving spinner
        this.setState({ savingNewAccessLevel: null });

        // Show the mutation error
        FlashesStore.flash(FlashesStore.ERROR, transaction.getError());
      }
    });
  };
github buildkite / frontend / app / components / member / Teams / row.js View on Github external
performRemove = () => {
    this.setState({ removing: true });

    const mutation = new TeamMemberDeleteMutation({
      teamMember: this.props.teamMember
    });

    Relay.Store.commitUpdate(mutation, {
      onFailure: (transaction) => {
        // Remove the "removing" spinner
        this.setState({ removing: false });

        // Show the mutation error
        FlashesStore.flash(FlashesStore.ERROR, transaction.getError());
      }
    });
  }
}
github buildkite / frontend / app / components / team / Pipelines / chooser.js View on Github external
this.props.relay.setVariables({ pipelineAddSearch: '' });

    const query = Relay.QL`mutation TeamPipelineCreateMutation {
      teamPipelineCreate(input: $input) {
        clientMutationId
      }
    }`;

    const variables = {
      input: {
        teamID: this.props.team.id,
        pipelineID: pipeline.id
      }
    };

    const mutation = new Relay.GraphQLMutation(query, variables, null, Relay.Store, {
      onFailure: this.handleMutationFailure,
      onSuccess: this.handleMutationSuccess
    });

    mutation.commit();
  };
github meedan / check-web / src / app / components / source / UserPrivacy.js View on Github external
handleRequestDeleteAccount() {
    const { user } = this.props;

    const onFailure = (transaction) => {
      const fallbackMessage = this.props.intl.formatMessage(globalStrings.unknownError, { supportEmail: stringHelper('SUPPORT_EMAIL') });
      const message = getErrorMessage(transaction, fallbackMessage);
      this.setState({ message });
    };

    const onSuccess = () => {
      logout();
    };

    Relay.Store.commitUpdate(
      new DeleteCheckUserMutation({
        id: user.dbid,
      }),
      { onSuccess, onFailure },
    );
  }
github meedan / check-web / src / app / components / project / ProjectAssignment.js View on Github external
const fallbackMessage = this.props.intl.formatMessage(globalStrings.unknownError, { supportEmail: stringHelper('SUPPORT_EMAIL') });
      const message = getErrorMessage(transaction, fallbackMessage);
      this.context.setMessage(message);
    };

    const onSuccess = () => {
      const message = (
        
      );
      this.context.setMessage(message);
    };

    Relay.Store.commitUpdate(
      new UpdateProjectMutation({
        id: this.props.project.id,
        assigned_to_ids: selected.join(','),
      }),
      { onSuccess, onFailure },
    );

    this.handleClose();
  };
github meedan / check-web / src / app / components / team / JoinTeamComponent.js View on Github external
this.setState({ message });
    };

    const onSuccess = (response) => {
      const appName = mapGlobalMessage(this.props.intl, 'appNameHuman');
      const { createTeamUser: { team_user: { status } } } = response;
      const message = status === 'member' ? messages.autoApprove : messages.success;
      this.setState({
        message: this.props.intl.formatMessage(message, {
          team: this.props.team.name, appName,
        }),
        requestStatus: status,
      });
    };

    Relay.Store.commitUpdate(
      new CreateTeamUserMutation({
        team_id: this.props.team.dbid,
        user_id: this.getContext().currentUser.dbid,
        status: 'requested',
      }),
      { onSuccess, onFailure },
    );
  }
github meedan / check-web / src / app / components / media / CreateRelatedMedia.js View on Github external
handleSubmit = (value) => {
    const onFailure = (transaction) => {
      const fallbackMessage = this.props.intl.formatMessage(globalStrings.unknownError, { supportEmail: stringHelper('SUPPORT_EMAIL') });
      const message = getErrorMessage(transaction, fallbackMessage);
      this.setState({ message, isSubmitting: false, dialogOpen: true });
    };

    const onSuccess = () => {
      this.setState({ message: null, isSubmitting: false });
    };

    const context = new CheckContext(this).getContextStore();

    Relay.Store.commitUpdate(
      new CreateProjectMediaMutation({
        ...value,
        context,
        project: this.props.media.project,
        team: this.props.media.team,
        related: this.props.media,
        related_to_id: this.props.media.dbid,
        targets_count: this.props.media.relationships.targets_count,
        relationships_target_id: this.props.media.relationships.target_id,
        relationships_source_id: this.props.media.relationships.source_id,
      }),
      { onSuccess, onFailure },
    );

    this.setState({ isSubmitting: true, dialogOpen: false });
  };