Suggestion: Generic OData response type

Aperta
#299 1 commento 5 reazioni 1 assegnatario Vedi su GitHub

@nikithauc ci sta già lavorando.

Dal 5/4/2022.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

enhancement

I think this library should include a type to match the OData response signature, as these properties are very important to consider in certain scenarios and I don't think the library consumer should have to define this type themselves or have to rely on another library.

Concretely, I suggest an implementation that ideally enables the following Angular code to compile

(this.http as HttpClient)
      .get<ExampleODataType<User>>('https://graph.microsoft.com/v1.0/me')
      .subscribe((response) => {
        console.log(response['@odata.context']);
        console.log(response.displayName);
      });
      
(this.http as HttpClient)
      .get<ExampleODataType<User[]>>('https://graph.microsoft.com/v1.0/users?$count')
      .subscribe((response) => {
        console.log(response['@odata.count']);
        console.log(response['@odata.nextLink']);
        console.log(response.value[0].displayName);
      });  
      

A simpler alternative to this could be a Type containing just the OData properties which one can make intersections with

(this.http as HttpClient)
      .get<User & ExampleODataType>('https://graph.microsoft.com/v1.0/me')
      .subscribe((response) => {
        console.log(response['@odata.context']);
        console.log(response.displayName);
      });
      
(this.http as HttpClient)
      .get<{ value: User[] } & ExampleODataType>('https://graph.microsoft.com/v1.0/users?$count')
      .subscribe((response) => {
        console.log(response['@odata.count']);
        console.log(response['@odata.nextLink']);
        console.log(response.value[0].displayName);
      });  
      
Lingua principale
PowerShell
Stelle
129
Fork
35
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoftgraph/msgraph-typescript-typings

Tutte le issue di microsoftgraph/msgraph-typescript-typings

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.