feathers-plus / generator-feathers-plus

A Yeoman generator to (re)generate a FeathersJS application supporting both REST and GraphQL architectural concepts and their query languages.

Home Page:https://generator.feathers-plus.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GraphQL response doesn't include id

sushil-iamplus opened this issue · comments

Steps to reproduce

  1. Generate app, authentication. (https://generator.feathers-plus.com/get-started/)
  2. Follow guide and add email and password field to user schema.
  3. Generate graphql (with auth)
  4. Run the app and create new user and access token.
  5. Open GraphiQL and Set Authorization Header with access token.
  6. Run query.
    { findUser(query: {}) { id email } }
  7. 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"
      }
    ]
  }
}
  1. Change id to _id in users.schema.js and re run feathers-plus g all or feathers-plus g graphql.
  2. Run app now and run above query with _id. Response will have _id with correct value.
  3. 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.
  4. 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.