{"id":2563,"date":"2019-02-22T16:43:15","date_gmt":"2019-02-22T16:43:15","guid":{"rendered":"https:\/\/developer.microsoft.com\/en-us\/office\/blogs\/?p=2563"},"modified":"2019-02-22T16:43:15","modified_gmt":"2019-02-22T16:43:15","slug":"microsoft-graph-sdk-for-javascript-release-notes","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/microsoft-graph-sdk-for-javascript-release-notes\/","title":{"rendered":"Microsoft Graph SDK for JavaScript Release Notes"},"content":{"rendered":"<p>We recently updated our JavaScript Graph SDK to version 1.4.0 and our Typescript Graph Types package to 1.6.0. The SDK release includes several new features and some bug fixes. The Typescript types includes updates to the models for Teams and Devices.<\/p>\n<h2>Page Iterator<\/h2>\n<p>Often collections of entities are split into pages and each page is returned with a URL to the next page.\u00a0 The PageIterator class simplifies consuming paged collections.\u00a0 Simply provide a callback method that will operate on each item in the paged collection and call the Iterate method.\u00a0 The PageIterator class will take care of following the NextLinks for you.<\/p>\n<h3>Iterate over all the messages<\/h3>\n<pre><code class=\"language-js\">async function callingPattern() {\n  try {\n\t\/\/ Makes request to fetch mails list. Which is expected to have multiple pages of data.\n\tlet response: PageCollection = await client.api(\"\/me\/messages\").get();\n\n\t\/\/ A callback function to be called for every item in the collection. This call back should return boolean indicating whether not to continue the iteration process.\n\tlet callback: PageIteratorCallback = (data) =&gt; {\n\t\tconsole.log(data);\n\t\treturn true;\n\t};\n\n\t\/\/ Creating a new page iterator instance with client a graph client instance, page collection response from request and callback\n\tlet pageIterator = new PageIterator(client, response, callback);\n\n\t\/\/ This iterates the collection until the nextLink is drained out.\n\tpageIterator.iterate();\n  } catch (e) {\n\tthrow e;\n  }\n}\n<\/code><\/pre>\n<p>If you want to stop the iterator before it iterates through the entire collection, you can simply return false from the callback.<\/p>\n<h2>Added Search query param functionality<\/h2>\n<p>Use the .search() function to perform a free text search over a collection of entities.<\/p>\n<pre><code class=\"language-js\">try {\n\tlet res = await client\n\t\t.api(\"\/me\/people\")\n\t\t.search(\"dicaprio\")\n\t\t.get();\n\tconsole.log(res);\n} catch (error) {\n\tthrow error;\n}\n<\/code><\/pre>\n<h2>Bug Fixes:<\/h2>\n<ul>\n<li><a href=\"https:\/\/github.com\/microsoftgraph\/msgraph-sdk-javascript\/issues\/115\">Should interface AuthProviderCallback accept null on accessToken<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/microsoftgraph\/msgraph-sdk-javascript\/issues\/107\">OneNote Pages not being returned using contentUrl<\/a><\/li>\n<\/ul>\n<h2>JavaScript SDK<\/h2>\n<ul>\n<li><a href=\"https:\/\/www.npmjs.com\/package\/@microsoft\/microsoft-graph-client\">NPM Package <\/a><\/li>\n<li><a href=\"https:\/\/github.com\/microsoftgraph\/msgraph-sdk-javascript\/releases\/tag\/1.4.0\">GitHub Repo<\/a><\/li>\n<\/ul>\n<h2>Typescript Graph Types<\/h2>\n<ul>\n<li><a href=\"https:\/\/www.npmjs.com\/package\/@microsoft\/microsoft-graph-types\">NPM Package<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/microsoftgraph\/msgraph-typescript-typings\/releases\/tag\/1.6.0\">GitHub Repo<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>We recently updated our JavaScript Graph SDK to version 1.4.0 and our Typescript Graph Types package to 1.6.0. <\/p>\n","protected":false},"author":69114,"featured_media":25159,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-2563","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-microsoft-graph"],"acf":[],"blog_post_summary":"<p>We recently updated our JavaScript Graph SDK to version 1.4.0 and our Typescript Graph Types package to 1.6.0. <\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/2563","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/users\/69114"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/comments?post=2563"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/2563\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media\/25159"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media?parent=2563"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/categories?post=2563"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/tags?post=2563"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}