Skip to content

Custom service methods missing #113

Description

@EmileSpecs

For more context see:
https://github.com/feathersjs/feathers/issues/3576

When a custom service method is added it does not exist as part of the obj passed to objectHooks function.

The result is that an error is thrown:

throw new Error(`Can not apply hooks. '${method}' is not a function...`);

I have a custom service method: async change(data: any, params?: Params): Promise<any> {}

When logging the obj provided in objectHooks that method is not present:

cs {
  update:
   { [Function: update]
     original: [Function: update],
     Context: [class ContextClass extends BaseHookContext],
     createContext: [Function: createContext],
     [Symbol(@feathersjs/hooks)]:
      FeathersHookManager {
        _parent: null,
        _params: [Array],
        _middleware: [],
        _props: [Object],
        _defaults: undefined,
        app: [Feathers],
        method: 'update' } },
  find:
   { [Function: find]
     original: [Function: find],
     Context: [class ContextClass extends BaseHookContext],
     createContext: [Function: createContext],
     [Symbol(@feathersjs/hooks)]:
      FeathersHookManager {
        _parent: null,
        _params: [Array],
        _middleware: [],
        _props: [Object],
        _defaults: undefined,
        app: [Feathers],
        method: 'find' } },
  get:
   { [Function: get]
     original: [Function: get],
     Context: [class ContextClass extends BaseHookContext],
     createContext: [Function: createContext],
     [Symbol(@feathersjs/hooks)]:
      FeathersHookManager {
        _parent: null,
        _params: [Array],
        _middleware: [],
        _props: [Object],
        _defaults: undefined,
        app: [Feathers],
        method: 'get' } },
  create:
   { [Function: create]
     original: [Function: create],
     Context: [class ContextClass extends BaseHookContext],
     createContext: [Function: createContext],
     [Symbol(@feathersjs/hooks)]:
      FeathersHookManager {
        _parent: null,
        _params: [Array],
        _middleware: [],
        _props: [Object],
        _defaults: undefined,
        app: [Feathers],
        method: 'create' } },
  patch:
   { [Function: patch]
     original: [Function: patch],
     Context: [class ContextClass extends BaseHookContext],
     createContext: [Function: createContext],
     [Symbol(@feathersjs/hooks)]:
      FeathersHookManager {
        _parent: null,
        _params: [Array],
        _middleware: [],
        _props: [Object],
        _defaults: undefined,
        app: [Feathers],
        method: 'patch' } },
  remove:
   { [Function: remove]
     original: [Function: remove],
     Context: [class ContextClass extends BaseHookContext],
     createContext: [Function: createContext],
     [Symbol(@feathersjs/hooks)]:
      FeathersHookManager {
        _parent: null,
        _params: [Array],
        _middleware: [],
        _props: [Object],
        _defaults: undefined,
        app: [Feathers],
        method: 'remove' } } }

I don't know if the issue is in the feathers/hooks repo/package or if the issue is upstream in feathers.

I didn't have this issue in feathers 5.0.24 (if I remember correctly).

@daffl hope this gives you something more to work with.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions