GraphQL response doesn't include id
sushil-iamplus opened this issue · comments
Steps to reproduce
- Generate app, authentication. (https://generator.feathers-plus.com/get-started/)
- Follow guide and add email and password field to user schema.
- Generate graphql (with auth)
- Run the app and create new user and access token.
- Open GraphiQL and Set Authorization Header with access token.
- Run query.
{ findUser(query: {}) { id email } }
- Response should contain id for the record but id is null
{
"total": 1,
"limit": 10,
"skip": 0,
"data": {
"findUser": [
{
"id": null,
"email": "user@mail.com"
}
]
}
}
- Change id to _id in users.schema.js and re run feathers-plus g all or feathers-plus g graphql.
- Run app now and run above query with _id. Response will have _id with correct value.
- Example given in get-started guide is not consistent if mongoose is used. I couldn't find any mongoose example in @feathers-plus/cli-generator-example.
- Generator should use _id if mongoose is selected as db.
You have to define a _id: { type: 'ID' }
field in your model if your id field is named _id. The generator does not change the name of index fields based on the type of adapter the service uses.
I think this should be documented.
Projects improve through contributions. Perhaps you can contribute a PR for the docs.