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

V3: custom methods usage #122

Open
krislintigo opened this issue Apr 12, 2023 · 3 comments
Open

V3: custom methods usage #122

krislintigo opened this issue Apr 12, 2023 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@krislintigo
Copy link

While setup Feathers Pinia v3 I'm losing custom methods. Setup below:

export default defineNuxtPlugin((nuxt) => {
  const storageKey = 'feathers-jwt'
  const host =
    (import.meta.env.VITE_MYAPP_API_URL as string) || 'http://localhost:3030'
  const connection = socketio<ServiceTypes>(
    io(host, { transports: ['websocket'] })
  )

  const feathersClient = createClient(connection, {
    storageKey,
  })
  console.log('CREATE CLIENT', feathersClient.service('users'))
  const api = createPiniaClient(feathersClient, {
    pinia: nuxt.$pinia,
    // ssr: process.server,
    ssr: false,
    idField: '_id',
    whitelist: [],
    paramsForServer: [],
    skipGetIfExists: true,
    customSiftOperators: {},
  })
  console.log('CREATE PINIA CLIENT', api.service('users'))

  return { provide: { api } }
})

In this setup, all methods available in feathers client, but only default methods in pinia client api:
image

@marshallswain
Copy link
Owner

Oh good catch. I need to proxy those methods in the wrapping service.

@marshallswain marshallswain self-assigned this Apr 12, 2023
@marshallswain marshallswain added the bug Something isn't working label Apr 12, 2023
@marshallswain
Copy link
Owner

Hmm. The JS part is easy to support, but TS is another story. As a workaround, you can access custom methods at api.service('my-service').service.isUserExists, for example.

@marshallswain marshallswain added enhancement New feature or request and removed bug Something isn't working labels Apr 12, 2023
@marshallswain
Copy link
Owner

We've had some internal discussion on how to fix the headache with custom method types. We'll likely be changing how custom methods are called in Feathers v6. The syntax will be something like service('my-service').call('custom-method-name', data)

I'm going to postpone working on this issue until that time, because the TS work is prohibitive, at least for me.

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

No branches or pull requests

2 participants