Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: _id.map is not a function #90

Closed
rturk opened this issue Feb 5, 2016 · 3 comments
Closed

Error: _id.map is not a function #90

rturk opened this issue Feb 5, 2016 · 3 comments

Comments

@rturk
Copy link

rturk commented Feb 5, 2016

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",
@rturk
Copy link
Author

rturk commented Feb 5, 2016

@sibeliusseraphini

@rturk
Copy link
Author

rturk commented Mar 16, 2016

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

@rturk rturk closed this as completed Apr 4, 2016
@yoadsn
Copy link
Contributor

yoadsn commented Apr 10, 2016

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",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants