How to use the react-relay.commitMutation 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 relay-tools / relay-compiler-language-typescript / example / ts / mutations / MarkAllTodosMutation.ts View on Github external
function commit(
  environment: Environment,
  complete: boolean,
  todos: TodoList_viewer["todos"],
  user: TodoList_viewer,
) {
  return commitMutation(environment, {
    mutation,
    variables: {
      input: { complete },
    },
    optimisticResponse: getOptimisticResponse(complete, todos, user),
  })
}
github renanmav / relay-twitter / src / modules / common / mutation / UserRegisterWithEmailMutation.ts View on Github external
function commit(
  input: UserRegisterWithEmailInput,
  onCompleted: (response: UserRegisterWithEmailMutationResponse) => void,
  onError: (error: Error) => void
) {
  return commitMutation(Environment, {
    mutation,
    variables: {
      input
    },
    onCompleted,
    onError
  });
}
github jkettmann / universal-react-relay-starter-kit / client / mutation / LogoutMutation.js View on Github external
function commit({ environment, onCompleted, onError }) {
  const variables = { input: {} }

  commitMutation(environment, {
    mutation,
    variables,
    onCompleted,
    onError,
  })
}
github danger / peril / dashboard / src / components / partial / mutations / updateJSONURLMutation.tsx View on Github external
export const updateJSONURLMutation = (
  environment: Environment,
  options: UpdateJSONURLMutationOptions,
  onCompleted: (res: any) => void
) =>
  commitMutation(environment, {
    mutation,
    variables: options,
    onError: err => {
      throw err
    },
    onCompleted,
  })
github artsy / reaction / src / Components / Follow.tsx View on Github external
handleFollow() {
    const { artist, user, relay } = this.props
    if (user && user.id) {
      commitMutation(relay.environment, {
        mutation: graphql`
          mutation FollowArtistMutation($input: FollowArtistInput!) {
            followArtist(input: $input) {
              artist {
                __id
                is_followed
              }
            }
          }
        `,
        variables: {
          input: {
            artist_id: artist.id,
            unfollow: artist.is_followed,
          },
        },
github magma / magma / symphony / app / fbcnms-projects / inventory / app / mutations / EditUserMutation.js View on Github external
export default (
  variables: EditUserMutationVariables,
  callbacks?: MutationCallbacks,
  updater?: SelectorStoreUpdater,
) => {
  const {onCompleted, onError} = callbacks ? callbacks : {};
  commitMutation(RelayEnvironemnt, {
    mutation,
    variables,
    updater,
    onCompleted,
    onError,
  });
};
github kiwicom / smart-faq / src / mutations / ResetPassword.js View on Github external
return new Promise((resolve, reject) =>
    commitMutation(createEnvironment(), {
      mutation,
      variables,
      onCompleted: () => resolve(),
      onError: error => reject(error),
    }),
  );