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

type error for composite primary keys in service options #94

Closed
robbyphillips opened this issue May 14, 2020 · 1 comment · Fixed by #95
Closed

type error for composite primary keys in service options #94

robbyphillips opened this issue May 14, 2020 · 1 comment · Fixed by #95

Comments

@robbyphillips
Copy link
Contributor

  const options = {
    Model,
    id: ['entityId', 'otherEntityId'],
    paginate: app.get('paginate')
  }

Throws a type error, "string[] is not assignable to string", but according to the feathers-objection docs, this is how you use composite primary keys.

Unfortunately, I think fixing this also requires a change in feathers. It looks like the upstream feathers AdapterService class doesn't allow a way to override its options object type. So, even if we did

export interface ObjectionServiceOptions extends Omit<ServiceOptions, 'id'> {
  model: typeof Model;
  id: string | string[];  // <--change
  // ...
}

We would still get a type error here:

export class Service<T = any> extends AdapterService<T> implements InternalServiceMethods<T> {
  Model: typeof Model;
  options: ObjectionServiceOptions;
  // ...
}

The actual fix is probably to make the feathers AdapterService accept an additional type parameter: AdapterService<T = any, S = ServiceOptions>, or to change ServiceOptions, but I think that might be more breaking.

@dekelev
Copy link
Member

dekelev commented May 15, 2020

@daffl , can you please take a look at this?

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

Successfully merging a pull request may close this issue.

2 participants