microsoftgraph / msgraph-sdk-typescript

MIT License
21 stars 5 forks source link

Can't use client.chats.get() with expands as it blows up #521

Closed sebastienlevert closed 8 months ago

sebastienlevert commented 8 months ago

When using:

const chats = await client.me.chats.get({
      queryParameters: {
        expand: ['members', 'lastMessagePreview'],
        orderby: ['lastMessagePreview/createdDateTime desc'],
      },
    });

The generated RequestInformation:

RequestInformation {
  pathParameters: {
    baseurl: 'https://graph.microsoft.com/v1.0',
    'user%2Did': 'TokenToReplace'
  },
  queryParameters: {
    '%24expand': [ 'members', 'lastMessagePreview' ],
    '%24orderby': [ 'lastMessagePreview/createdDateTime desc' ]
  },
  headers: Headers(0) [Map] {
    headers: { accept: [Set] },
    singleValueHeaders: Set(3) { 'Content-Type', 'Content-Encoding', 'Content-Length' }
  },
  _requestOptions: {},
  setContentFromParsable: [Function (anonymous)],
  setContentAndContentType: [Function (anonymous)],
  getSerializationWriter: [Function (anonymous)],
  setContentFromScalar: [Function (anonymous)],
  setStreamContent: [Function (anonymous)],
  httpMethod: 'GET',
  urlTemplate: '{+baseurl}/users/{user%2Did}/chats{?%24count,%24expand,%24filter,%24orderby,%24search,%24select,%24skip,%24top}'
}

I automatically get an error

TypeError: Cannot read properties of null (reading '@odata.type')
    at JsonParseNode.getChildNode (/home/slevert/src/temp/mvp-msgraph-typescript/node_modules/@microsoft/kiota-serialization-json/dist/cjs/src/jsonParseNode.js:12:77)
    at createEventMessageDetailFromDiscriminatorValue (/home/slevert/src/temp/mvp-msgraph-typescript/node_modules/@microsoft/msgraph-sdk/models/index.js:9846:40)
    at JsonParseNode.getObjectValue (/home/slevert/src/temp/mvp-msgraph-typescript/node_modules/@microsoft/kiota-serialization-json/dist/cjs/src/jsonParseNode.js:57:88)
    at eventDetail (/home/slevert/src/temp/mvp-msgraph-typescript/node_modules/@microsoft/msgraph-sdk/models/index.js:27258:319)
    at /home/slevert/src/temp/mvp-msgraph-typescript/node_modules/@microsoft/kiota-serialization-json/dist/cjs/src/jsonParseNode.js:75:21
    at Array.forEach (<anonymous>)
    at JsonParseNode.assignFieldValues (/home/slevert/src/temp/mvp-msgraph-typescript/node_modules/@microsoft/kiota-serialization-json/dist/cjs/src/jsonParseNode.js:72:44)
    at JsonParseNode.getObjectValue (/home/slevert/src/temp/mvp-msgraph-typescript/node_modules/@microsoft/kiota-serialization-json/dist/cjs/src/jsonParseNode.js:62:18)
    at lastMessagePreview (/home/slevert/src/temp/mvp-msgraph-typescript/node_modules/@microsoft/msgraph-sdk/models/index.js:27148:410)
    at /home/slevert/src/temp/mvp-msgraph-typescript/node_modules/@microsoft/kiota-serialization-json/dist/cjs/src/jsonParseNode.js:75:21

When removing the expand, everything is back to normal.

RequestInformation:

RequestInformation {
  pathParameters: {
    baseurl: 'https://graph.microsoft.com/v1.0',
    'user%2Did': 'TokenToReplace'
  },
  queryParameters: { '%24orderby': [ 'lastMessagePreview/createdDateTime desc' ] },
  headers: Headers(0) [Map] {
    headers: { accept: [Set] },
    singleValueHeaders: Set(3) { 'Content-Type', 'Content-Encoding', 'Content-Length' }
  },
  _requestOptions: {},
  setContentFromParsable: [Function (anonymous)],
  setContentAndContentType: [Function (anonymous)],
  getSerializationWriter: [Function (anonymous)],
  setContentFromScalar: [Function (anonymous)],
  setStreamContent: [Function (anonymous)],
  httpMethod: 'GET',
  urlTemplate: '{+baseurl}/users/{user%2Did}/chats{?%24count,%24expand,%24filter,%24orderby,%24search,%24select,%24skip,%24top}'
}