microsoftgraph / msgraph-typescript-typings

Microsoft Graph TypeScript Type Definitions
https://graph.microsoft.com
Other
114 stars 33 forks source link

@odata properties missing #234

Open M1kep opened 3 years ago

M1kep commented 3 years ago

I've recently started using these typing and am running into some issues as it appears none of the types/interfaces contains any of the @odata.* properties. The two I've ran into are @odata.context and @odatda.type AB#8340

nikithauc commented 3 years ago

The msgraph-typescript-typings contains types representing the objects or entities and not the odata response. Please check the ReadMe for examples.

const res = await client.api(`/me/drive/root:/${ExcelFilename}:/workbook/worksheets`).get();
const worksheets = res.value as WorkbookWorksheet[];

const response  = await client.api(`/me/`).get();
const user = response  as User;

Please let me know if you have any more questions.

richban commented 3 years ago

@nikithauc in my case using v1.0 version:

    const appRoleAssignments = await client
      .api(`/servicePrincipals/${SERVICE_PRINCIPAL_ID}/appRoleAssignedTo`)
      .select("id")
      .select("principalId")
      .select("principalDisplayName")
      .select("principalType")
      .select("resourceId")
      .select("resourceDisplayName")
      .select("appRoleId")
      .get()
    return appRoleAssignments as AppRoleAssignment

I don't receive the AppROleAssignment type but this:

ss

can you elaborate why is this the case?

richban commented 3 years ago

Alright I just noticed what's my actual response is :)

    const client = getAuthenticatedClient(accessToken)
    const response = await client
      .api(`/servicePrincipals/${SERVICE_PRINCIPAL_ID}/appRoleAssignedTo`)
      .select("id")
      .select("principalId")
      .select("principalDisplayName")
      .select("principalType")
      .select("resourceId")
      .select("resourceDisplayName")
      .select("appRoleId")
      .get()
    const appRoleAssignments = response.value as AppRoleAssignment[]
    return appRoleAssignments
elliot-huffman commented 4 months ago

@nikithauc (bump) I have noticed that the readme doesn't appear to reference anything about odata, can a section be added back to the readme on how to remediate this situation or add the odata responses to the types? At the moment, I am bootlegging together the structures using union types.