Skip to content

Commit

Permalink
Fix #4, add clientMutationId.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Jul 10, 2018
1 parent 8e78fda commit bf4a89d
Show file tree
Hide file tree
Showing 8 changed files with 356 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .babelrc
@@ -1,9 +1,9 @@
{
"presets": ["babel-preset-expo"],
"plugins": ["relay"],
"env": {
"development": {
"plugins": [
["relay", { "schema": "schema/schema.graphql" }],
"transform-react-jsx-source"
]
}
Expand Down
13 changes: 10 additions & 3 deletions app/mutations/CreateMeetingMutation.js
@@ -1,9 +1,11 @@
import { graphql } from 'react-relay'
import commitMutation from 'relay-commit-mutation-promise'
import { graphql } from 'react-relay';
import commitMutation from 'relay-commit-mutation-promise';
import uuid from 'uuid/v4';

const mutation = graphql`
mutation CreateMeetingMutation($input: createMeetingInput!) {
createMeeting(input: $input) {
clientMutationId,
meeting {
id
title
Expand All @@ -20,7 +22,12 @@ const mutation = graphql`
`

function commit(userId, { environment, input }) {
const variables = { input }
const variables = {
input: {
clientMutationId: uuid(),
...input
}
}

return commitMutation(environment, {
mutation,
Expand Down
9 changes: 8 additions & 1 deletion app/mutations/CreateUserMutation.js
@@ -1,9 +1,11 @@
import { graphql } from 'react-relay'
import commitMutation from 'relay-commit-mutation-promise'
import uuid from 'uuid/v4';

const mutation = graphql`
mutation CreateUserMutation($input: createUserInput!) {
createUser(input: $input) {
clientMutationId,
user {
id
}
Expand All @@ -12,7 +14,12 @@ const mutation = graphql`
`

function commit({ environment, input }) {
const variables = { input }
const variables = {
input: {
clientMutationId: uuid(),
...input
}
}

return commitMutation(environment, {
mutation,
Expand Down
9 changes: 8 additions & 1 deletion app/mutations/DeleteMeetingMutation.js
@@ -1,16 +1,23 @@
import { graphql } from 'react-relay'
import commitMutation from 'relay-commit-mutation-promise'
import uuid from 'uuid/v4';

const mutation = graphql`
mutation DeleteMeetingMutation($input: deleteMeetingInput!) {
deleteMeeting(input: $input) {
clientMutationId,
deletedId
}
}
`

function commit(userId, { environment, input }) {
const variables = { input }
const variables = {
input: {
clientMutationId: uuid(),
...input
}
}

return commitMutation(environment, {
mutation,
Expand Down
9 changes: 8 additions & 1 deletion app/mutations/LoginMutation.js
@@ -1,9 +1,11 @@
import { graphql } from 'react-relay'
import commitMutation from 'relay-commit-mutation-promise'
import uuid from 'uuid/v4';

const mutation = graphql`
mutation LoginMutation($input: loginInput!) {
login(input: $input) {
clientMutationId,
user {
id
}
Expand All @@ -12,7 +14,12 @@ const mutation = graphql`
`

function commit({ environment, input }) {
const variables = { input }
const variables = {
input: {
clientMutationId: uuid(),
...input
}
}

return commitMutation(environment, {
mutation,
Expand Down

0 comments on commit bf4a89d

Please sign in to comment.