ParseReact icon indicating copy to clipboard operation
ParseReact copied to clipboard

Inconsistent pointer type in query results after issuing Mutation.Create

Open mikemintz opened this issue 10 years ago • 3 comments

I have a query that automatically updates when I issue a Mutation.Create. However, the pointer values of my results are inconsistent between objects that were pulled from the server and objects that were just added via the Mutation.Create.

  • The objects that came from the server were flattened, so their id is in a field called objectId.
  • The objects that came from the mutation are ordinary parse object pointers (just like in the Mutation.Create), so their id is in a field called id.

This makes it challenging to use query results, since I constantly have to check what type the pointers are.

Below is an example component where this occurs:

const React = require('react');
const Parse = require('parse').Parse;
const ParseReact = require('parse-react');

const Comment = Parse.Object.extend('Comment');
const User = Parse.Object.extend('User');

const CommentBox = React.createClass({
  mixins: [ParseReact.Mixin],

  observe() {
    return {comments: new Parse.Query(Comment)};
  },

  handleNewComment(event) {
    event.preventDefault();
    ParseReact.Mutation.Create('Comment', {
      body: React.findDOMNode(this.refs.newComment).value,
      user: new User({id: this.props.curUser.objectId}),
    }).dispatch();
  },

  render() {
    console.log(this.data.comments.map(x => x.user.id));
    console.log(this.data.comments.map(x => x.user.objectId));
    return (
      <form onSubmit={this.handleNewComment}>
        <input type="text" ref="newComment" />
        <button type="submit">Send</button>
      </form>
    );
  },
});

module.exports = CommentBox;

When loading the page, the console log looks like:

[Id, Id]
["W4fOmMXg", "W4fOmMXg"]

After submitting a comment, it outputs:

[Id, Id, "W4fOmMXg"]
["W4fOmMXg", "W4fOmMXg", undefined]

mikemintz avatar May 23 '15 20:05 mikemintz

bump. this is a pretty clear bug

roddylindsay avatar Jul 14 '15 23:07 roddylindsay

Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed.

ghost avatar Aug 04 '15 19:08 ghost

Any updates about this? does this also happen when using parse-react with parse-sdk-js 1.6.14?

DeDuckProject avatar Sep 02 '16 21:09 DeDuckProject