marshallswain / feathers-pinia

Connect your Feathers API to the elegant data store for Vue
52 stars 22 forks source link

Feathers __isStoreInstance but not __isServiceInstance #139

Closed kornalius closed 11 months ago

kornalius commented 11 months ago

Hello,

I am working on an app that allows creating dynamic services and on the frontend side the store 'service:...' is created but its functionalities don't seem to be connected to the service.

In the createPiniaClient setup, I don't declare the dynamic services in the services section.

I would like to be able to declare the stores to be used as regular services (on the backend the service exists).

If I do the following, it seems to create a defaultService but without being connected to the service on the backend.

const doc = api.service('dynServiceName').new()
doc.createInStore()  // <<-- error, not a function
doc.__isServiceInstance // <<--- not there, however __isStoreInstance is there

In the defaultService() in create-pinia-client.ts I see that useServiceInstance should be called it does not seem to.

Is there a way to create a connected service store with going through createPiniaClient?

kornalius commented 11 months ago

I found my issue. The problem lied in the global 'setupInstance' method in the createPiniaClient. I re-creating the data like the following:

setupInstance(data: AnyData): AnyData {
  return {
    _id: undefined,
    ...data,
  }
}

That was destroying the instance.