MongoDB.live, free & fully virtual. June 9th - 10th. Register Now MongoDB.live, free & fully virtual. June 9th - 10th. Register Now

Stitch many to many relationship

Hello,

I want to model a list of persons who make visits :

    {
      "title": "visit",
      "properties": {
        "_id": {
          "bsonType": "objectId"
        },
        "date": {
          "bsonType": "string"
        },
        "hour": {
          "bsonType": "string"
        },
        "persons": {
          "bsonType": "array",
          "items": {
            "bsonType": "objectId"
          }
        }
      }
    }

I have declared this relation:

    {
      "persons": {
        "ref": "#/stitch/mongodb-atlas/handmirable/person",
        "foreign_key": "_id",
        "is_list": true
      }
    }

The stitch generated graphql schema is:

    type Visit {
      _id: ObjectId
      date: String
      hour: String
      persons: [Person]
    }

    input VisitInsertInput {
      date: String
      hour: String
      _id: ObjectId
    }

    input VisitQueryInput {
      hour: String
      persons: [PersonQueryInput]
      _id: ObjectId
      date: String
    }

    input VisitUpdateInput {
      hour: String
      _id: ObjectId
      date: String
    }

I don’t understand why the field “persons” disappear in VisitInsertInput and VisitUpdateInput. I can query my visitors but can’t create or update them. Is my model wrong?

Hi Vincent – Unfortunately this was a bug on our end but it has now been addressed.