Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

arg parameters in resolve don't inherit from Object #177

Description

@pszabop

Given a resolve function that looks like

resolve: (root, args, request) => {
  test =  { uuid: '1234', description: 'lead singer of the Doors' };
  console.log('result: ' + Object.prototype.hasOwnProperty.call(args.person, 'description'));
  // XXX This fails!:  console.log('result: ' + args.person.hasOwnProperty('description'));
  console.log('result: ' + test.hasOwnProperty('description'));
  return db.personUpdate(request.user, args.person);
}

If I try to use args.person.hasOwnProperty('description') I get the error hasOwnProperty is not a function. I'm forced to use Object.prototype.hasOwnProperty.call per this issue in another module

Note that if I create an object similar to args.person I don't get an error. See the test example in the code snippet.

I'm not enough of a javascript guru to say why this is happening, but it is a gotcha for when I"m attempting an update, where I merge the update with the existing object depending on what attributes are set in the update. My unit tests for the database pass (e.g. just like the test object above), but then fails when I attempt have graphql-express use my database.

I've checked, and there is no attribute 'hasOwnProperty' on args.person, per the Mozilla description of Object.hasOwnProperty

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions