mobql icon indicating copy to clipboard operation
mobql copied to clipboard

Feature: Better API for registering objects

Open Rodentman87 opened this issue 4 years ago • 0 comments

Currently, the API for registering objects doesn't work well for adding features without getting very verbose, and has potential for breaking changes to the API. The API should be switched to options passed as an object so that new options can be added without creating a breaking change.

Current API

registerListType<T extends DataLoadedListEntry>(
    object: new (id: string, manager: DataLoadedListEntryManager<any>) => T,
    queryName: string,
    typename?: string,
    idName: string = "id",
    idType: string = "ID!"
  )

registerObject<T extends DataLoadedObject>(
    object: new (...args: any[]) => T,
    queryName: string,
    typename?: string
  )

Proposed API

registerListType<T extends DataLoadedListEntry>(
  object: new (id: string, manager: DataLoadedListEntryManager<any>) => T,
  options: ListTypeOptions,
 )

registerObject<T extends DataLoadedObject>(
    object: new (...args: any[]) => T,
    options: ObjectTypeOptions,
  )

Rodentman87 avatar Apr 12 '21 02:04 Rodentman87