Graphback: an `id` entry is added in mongo document during update

Created on 25 Jun 2020  路  3Comments  路  Source: aerogear/graphback

If you have a model like this

""" 
@model
@datasync
"""
type Comment {
  id: ID!
  text: String
  description: String
}

And you attempt to add an document, a phantom field id is added to your document.

update mutation

mutation {
  updateComment(
    input: {
      id: "5ef49c9282b11580bbf2df47"
      description: "changed"
      updatedAt: "1593089170592"
    }
  ) {
    text
    description
    updatedAt
  }
}

resulting document in database

{
 "_id" : ObjectId("5ef49c9282b11580bbf2df47"), 
"text" : "comment", 
"description" : "changed", 
"noteId" : "5ef49c2682b11580bbf2df3c", 
"_deleted" : false, 
"createdAt" : 1593089170592, 
"updatedAt" : 1593089915855, 
"id" : "5ef49c9282b11580bbf2df47" 
}

I think it could be coming from here https://github.com/aerogear/graphback/blob/master/packages/graphback-runtime-mongodb/src/MongoDBDataProvider.ts#L64 maybe we should strip it out from data before update?

bug

Most helpful comment

This is duplicate of what @ssd71 is going to try solve. We have this mapping and this will go away

All 3 comments

/cc @wtrocki @craicoverflow @ssd71

This is duplicate of what @ssd71 is going to try solve. We have this mapping and this will go away

This is duplicate of what @ssd71 is going to try solve. We have this mapping and this will go away

Cool. Closing this in favour of https://github.com/aerogear/graphback/issues/1547 which has a good discussion around the general issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wtrocki picture wtrocki  路  6Comments

ankitjena picture ankitjena  路  5Comments

PixelYeti picture PixelYeti  路  5Comments

b1zzu picture b1zzu  路  4Comments

b1zzu picture b1zzu  路  7Comments