Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set property 'clientMutationId' of undefined #620

Closed
ansarizafar opened this issue Nov 20, 2015 · 3 comments
Closed

Cannot set property 'clientMutationId' of undefined #620

ansarizafar opened this issue Nov 20, 2015 · 3 comments

Comments

@ansarizafar
Copy link

I am getting following error. when trying to run a mutation via graphiql

mutation {
 createUser (input: {username: "Hamza Khan", clientMutationId: ""}) {
   user {
    id
  username
}
}

}

{
  "data": {
    "createUser": null
  },
  "errors": [
    {
      "message": "Cannot set property 'clientMutationId' of undefined",
      "locations": [
        {
          "line": 17,
          "column": 2
        }
      ]
    }
  ]
}

Here is the mutation definition

import {
  GraphQLString,
  GraphQLInt,
  GraphQLFloat,
  GraphQLList,
  GraphQLObjectType,
  GraphQLID,
  GraphQLNonNull
} from 'graphql';

import {
  connectionArgs,
  connectionDefinitions,
  connectionFromArray,
  fromGlobalId,
  globalIdField,
  mutationWithClientMutationId,
  nodeDefinitions,
} from 'graphql-relay';

import {User} from './usermodel';
import {UserType} from './usertype';

export const UserMutations = {};
UserMutations.createUser = mutationWithClientMutationId({
  name: 'CreateUser',
  inputFields: {
    username: {type: new GraphQLNonNull(GraphQLString)}
  },
  outputFields: {
    user: {
      type: UserType,
      resolve: (payload) => {
console.log(payload);
        return User.getUserById(payload.userId);
      }
    }
  },
  mutateAndGetPayload: (args) => {
      let newUser = new User({ username: args.username });
    newUser.save().then((user) => {
        return {userId: user.id};
    }).error((err) => {return null;});
    }
});
@josephsavona
Copy link
Contributor

Thanks for your question!

We want to make sure to keep signal strong in the GitHub issue tracker – to make sure that it remains the best place to track issues that affect the development of Relay.

Questions like yours deserve a purpose-built Q&A forum. Would you like to post this question to Stack Overflow with the tag #relayjs? We'll be happy to answer there. Post a link to your Stack Overflow question here, to so that we don't lose track of it.

https://stackoverflow.com/questions/ask?tags=relayjs

@ansarizafar
Copy link
Author

@josephsavona I have posted this question to Stack Overflow. Here is the link

https://stackoverflow.com/questions/33831911/cannot-set-property-clientmutationid-of-undefined

@josephsavona
Copy link
Contributor

thanks for posting on SO, let's continue discussion there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants