RisingStack / graffiti-mongoose

⚠️ DEVELOPMENT DISCONTINUED - Mongoose (MongoDB) adapter for graffiti (Node.js GraphQL ORM)

Home Page:https://risingstack-graffiti.signup.team/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: _id.map is not a function

rturk opened this issue · comments

I get an error if I use after to fetch new items. Example query (below). Query is produced by Relay, but should be self explanatory.

query Product {
  node(id:"UHJvZHVjdDo1MGEwNDU1ZDBkNmNhYjA1MmFlN2VmZTk=") {
    ...F1
  }
}

fragment F0 on Attribute {
  id,
  name
}

fragment F1 on Product {
  _attributeslhN3L:attributes(after:"Y29ubmVjdGlvbi41NDVhYzUzY2JlYjcwODYzMWJjODczYTA=",first:2) {
    edges {
      cursor,
      node {
        ...F0,
        id
      }
    },
    pageInfo {
      hasNextPage,
      hasPreviousPage
    }
  },
  id
}

If I run the same query without after it will run successfully, even with a higher number of items

This is my (redacted) model structure:

ProductSchema = new mongoose.Schema({
  name: { type: String, required: true,
  },
  attributes: { type: [{ type: ObjectId, ref: 'Attribute' }], index: true },
})..
Attribute = new mongoose.Schema({
  name: {
    type: 'String',
    description: 'name of the attribute',
    maxLength: 60,
    required: true
  })..

I'm using:

"@risingstack/graffiti": "^3.0.1",
"@risingstack/graffiti-mongoose": "^5.0.5",
"express": "^4.13.4",
"mongoose": "^4.3.7",

@sibeliusseraphini

With @risingstack/graffiti-mongoose": "^5.0.9" I can run the query.
However still get some errors messages. Looks like this will be fully resolved with #100

Hey,
I'm getting this error when trying simple pagination from GrapihQL.
I'm on grafitti-mongoose 5.0.10 and as far as I can tell this is not resolved by #100.

The mongoose schema I am using (reduced for brevity):

var itemSchema = Schema({
  title: String,
  description: String,
  slug: String,
  tags: String,
  updatedAt: { type: Date, default: Date.now },
  relatedItems: [{ type: Schema.Types.ObjectId, ref: 'Item' }]
});

And the query resulting in the error:

{
  items(id: "570a6a89d675be1c3006dac8") {
    _id
    relatedItems(first: 2, after: "Y29ubmVjdGlvbi41NzBhNmE4OWQ2NzViZTFjMzAwNmRhY2E=") {
      edges {
        cursor
        node {
          _id
        }
      }
    }
  }
}

Let me know if I can provide any more information on this problem.

"graphql": "^0.5.0",
"mongoose": "^4.4.12"
"@risingstack/graffiti": "^3.0.3",
"@risingstack/graffiti-mongoose": "^5.0.10",