msgraph-typescript-typings
msgraph-typescript-typings copied to clipboard
No type for API responses that return a list of values
I've found that when querying endpoints such as https://graph.microsoft.com/v1.0/groups I cannot find any types that match up with the response structure shown below:
interface valuesResponseExample<T> {
@odata.context: string,
@odata.nextLink?: string,
value: T[]
}
Is this the intended behavior, and if so what is the suggested method for working around this? AB#8341
@M1kep This is intended behavior.
Example of using the Group type in this case -
const res = await client.api("/groups").get();
const group = res.value[0] as Group;
Please let me know if you have any more questions.
+1. Having types that encompass the @odata fields (both in the envelope and inside the entity) would be cool, especially for delta sync endpoints to easily get at @odata.nextLink and @odata.deltaLink.
I defined my own type for this purpose:
type ODataResponse<T> = {
[key: string]: any;
value: T[];
}
Maybe it could be expanded upon to actually list some the valid @odata properties for ease of use if you need them in code? (e.g. @odata.nextLink)
Bit out of topic but how can I remove the @data props from each response?

@M1kep This is intended behavior.
I think this really shouldn't be the intended behavior