How to use the react-relay.Mutation 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 nikolasburk / relay-modern-migration-example / src / mutations / RemoveTodoMutation.js View on Github external
import Relay from 'react-relay'

export default class RemoveTodoMutation extends Relay.Mutation {
  static fragments = {
    // TODO: Mark complete as optional
    todo: () => Relay.QL`
      fragment on Todo {
        complete,
        id,
      }
    `,
    // TODO: Mark completedCount and totalCount as optional
    viewer: () => Relay.QL`
      fragment on Viewer {
        id,
      }
    `,
  }
  getMutation () {
github DevelopIntelligenceBoulder / react-flux-blog / blog-post-5+6 / src / www / js / mutations / update-widget-mutation.js View on Github external
import Relay from 'react-relay';

export default class extends Relay.Mutation {
	
	static fragments = {
		viewer: () => Relay.QL`fragment on Viewer { id }`
	}
	
	getMutation() {
		return Relay.QL`mutation { updateWidget }`;
	}
	
	// receives the parameters from the constructor, builds
	// the variables to send the GraphQL server
	getVariables() {
		return {
			widget: {
				// id is included because we are updating, input type must accept id
				id: this.props.id,
github gauravtiwari / relay-rails-blog / client / app / bundles / Mutations / CreateComment.js View on Github external
import Relay from 'react-relay';
import showdown from 'showdown';
import moment from 'moment';
const converter = new showdown.Converter();

/* global App */

export default class extends Relay.Mutation {
  getMutation() {
    return Relay.QL`mutation{CreateComment}`;
  }

  getFatQuery() {
    return Relay.QL`
      fragment on CreateCommentPayload {
        commentEdge,
        post {
          comments_count
        }
    }
    `;
  }

  getConfigs() {
github DefinitelyTyped / DefinitelyTyped / react-relay / react-relay-tests.tsx View on Github external
import * as React from "react"
import * as Relay from "react-relay"

interface Props {
    text: string
    userId: string
}

interface Response {
}

export default class AddTweetMutation extends Relay.Mutation {

    getMutation () {
        return Relay.QL`mutation{addTweet}`
    }

    getFatQuery () {
        return Relay.QL`
            fragment on AddTweetPayload {
                tweetEdge
                user
            }
        `
    }

    getConfigs () {
        return [{
github carlpeaslee / tictacturing / src / mutations / SigninUser.js View on Github external
import Relay from 'react-relay'

export default class SigninUserMutation extends Relay.Mutation {
  getMutation() {
    return Relay.QL`mutation {signinUser}`
  }

  getFatQuery() {
    return Relay.QL`fragment on SigninPayload {
      token
      viewer {
        user
      }
      user
    }`
  }

  getConfigs() {
    return [
github scaphold-io / react-relay-starter-kit / js / mutations / RegisterMutation.js View on Github external
import Relay from 'react-relay';

export default class RegisterMutation extends Relay.Mutation {
  static initialVariables = {
    input: null
  };

  getMutation() {
    return Relay.QL`
      mutation {
        createUser
      }
    `;
  }

  getVariables() {
    return {
      username: this.props.input.username,
      password: this.props.input.password
github MikeBild / graphql-pouch / example / cms-relay / src / app / components / PostUpdate.jsx View on Github external
<div>{`Revision: ${this.props.post.rev}`}</div>
        <hr>
        <div>
          <input placeholder="Enter a post title" type="text">
        </div>
        <div>
          <input placeholder="Enter a post body" type="text">
        </div>
        <hr>
        <div><button>Update</button></div>
      
    )
  }
}

class PostMutation extends Relay.Mutation { 
  getVariables() {
    return {
      id: this.props.id,
      rev: this.props.rev,
      title: this.props.title,
      body: this.props.body,
      blogId: this.props.blogId || 'myblog', 
      personId: this.props.personId || 'joe'
    };
  }
  getConfigs() {
    return [{
      type: 'FIELDS_CHANGE',
      fieldIDs: {
        post: this.props.id,
      }