Skip to content
This repository has been archived by the owner on Oct 14, 2020. It is now read-only.

Unable to regenerate validate and mongoose schemas #41

Closed
abhisekp opened this issue Sep 15, 2018 · 2 comments
Closed

Unable to regenerate validate and mongoose schemas #41

abhisekp opened this issue Sep 15, 2018 · 2 comments

Comments

@abhisekp
Copy link

abhisekp commented Sep 15, 2018

Expected behavior

The regenerate using feathers-plus g service and then users service should regenerate the mongoose and validate schemas after editing the schema file.

Schema File

// Define the Feathers schema for service `users`. (Can be re-generated.)
// !code: imports // !end
// !code: init // !end

// Define the model using JSON-schema
let schema = {
  // !<DEFAULT> code: schema_header
  title: 'Users',
  description: 'Users database.',
  // !end
  // !code: schema_definitions // !end

  // Required fields.
  required: [
    // !code: schema_required
    'username',
    // !end
  ],
  // Fields with unique values.
  uniqueItemProperties: [
    // !code: schema_unique
    'username',
    // !end
  ],

  // Fields in the model.
  properties: {
    // !code: schema_properties
    id: { type: 'ID' },
    name: {
      type: 'object',
      properties: {
        firstName: {
          type: 'string',
          minLength: 2,
          maxLength: 15,
          faker: 'name.firstName',
        },
        lastName: {
          type: 'string',
          minLength: 2,
          maxLength: 15,
          faker: 'name.lastName',
        },
      },
    },
    username: { type: 'string', faker: 'internet.userName' },
    password: { type: 'string', chance: { hash: { length: 60 } } },
    email: {
      type: 'string',
      minLength: 8,
      maxLength: 40,
      faker: 'internet.email',
    },
    // !end
  },
  // !code: schema_more // !end
};

// Define optional, non-JSON-schema extensions.
let extensions = {
  // GraphQL generation.
  graphql: {
    // !code: graphql_header
    name: 'User',
    service: {
      sort: { _id: 1 },
    },
    // sql: {
    //   sqlTable: 'Users',
    //   uniqueKey: '_id',
    //   sqlColumn: {
    //     __authorId__: '__author_id__',
    //   },
    // },
    // !end
    discard: [
      // !code: graphql_discard // !end
    ],
    add: {
      // !<DEFAULT> code: graphql_add
      // __author__: { type: '__User__!', args: false, relation: { ourTable: '__authorId__', otherTable: '_id' } },
      // !end
    },
    // !code: graphql_more // !end
  },
};

// !code: more // !end

let moduleExports = {
  schema,
  extensions,
  // !code: moduleExports // !end
};

// !code: exports // !end
module.exports = moduleExports;

// !code: funcs // !end
// !code: end // !end

Actual behavior

The mongoose and validate files are not regenerated.

? What is the name of the service? users

We are updating an existing service in dir chatapp-api-plus

Run "feathers-plus generate graphql" afterwards if you want any
schema changes to also be handled in GraphQL.

? What is the name of the service? users
? What would you call one row in the users database? user
? What kind of service is it? Mongoose
? Place service code in which nested folder, e.g. `v1/blog`? (optional) admin
? Which path should the service be registered on? /users
? Does the service require authentication? Yes
? Should this be served by GraphQL? Yes
     skip src/typings.d.ts
     skip src/mongoose.js
     skip src/typings.d.ts
     skip src/mongoose.js
     skip test/services/users.test.js
     skip src/services/admin/users/users.class.js
     skip src/services/admin/users/users.interface.js
     skip src/app.interface.ts
     skip src/typings.d.ts
    force config/default.json
    force src/app.js
    force src/models/admin/users.model.js
    force src/services/admin/users/users.service.js
    force src/services/admin/users/users.schema.js
    force src/services/admin/users/users.mongo.js
    force src/services/admin/users/users.mongoose.js
    force src/services/admin/users/users.sequelize.js
    force src/services/admin/users/users.validate.js
    force src/services/admin/users/users.hooks.js
    force src/services/index.js

NodeJS version:
v10.1.0

Operating System:
Distributor ID: LinuxMint
Description: Linux Mint 18.3 Sylvia
Release: 18.3
Codename: s

@abhisekp
Copy link
Author

I think it does not work if the service is inside a subdirectory.

@eddyystop
Copy link
Member

eddyystop commented Sep 16, 2018

Thanks for finding this and isolating the cause.

The name spacing test has been updated to check properties and graphql generation, not just folder structure. https://github.com/feathers-plus/generator-feathers-plus/tree/master/test-expands/name-space.test-expected

Fix published as f+/cli v0.7.27 using generator v0.6.26.

Please confirm it resolves the situation for yoiu.

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

No branches or pull requests

2 participants