I have the following case class:
  @GQLDirective(federation.Key("User Config"))
case class UserConfig(
                        userId: Int,
                        personalGroup: Option[PersonalGroup] = None,
                        accountGroup: Option[AccountGroup] = None
                       ) extends Bson {
    override def toBsonDocument[TDocument](documentClass: Class[TDocument], codecRegistry: CodecRegistry): BsonDocument = {
      new BsonDocumentWrapper[UserConfig](this, codecRegistry.get(classOf[UserConfig]))
    }
  }
And trying to update an already stored document this way:
def update(userConfig: UserConfig) = {
    collection.updateOne(equal("userId", 1), userConfig).headOption()
  }
But when I am trying to do so I have the following error:
Invalid BSON field name userId
I have also tried to use replaceOne method, but it will replace the whole object and erase the fields that I don't want to.
What I am trying to achieve: I want to save only changed fields in mongodb document. These fields are given by graphql request