{"id":222,"date":"2020-10-21T11:08:00","date_gmt":"2020-10-21T18:08:00","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/ifdef-windows\/?p=222"},"modified":"2021-02-09T11:13:41","modified_gmt":"2021-02-09T19:13:41","slug":"a-sneak-peek-of-new-features-with-microsoft-graph-toolkit-v2-0-0","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/ifdef-windows\/a-sneak-peek-of-new-features-with-microsoft-graph-toolkit-v2-0-0\/","title":{"rendered":"A Sneak Peek of New Features with Microsoft Graph Toolkit v2.0.0"},"content":{"rendered":"<p>It\u2019s hard to believe that just 1 year ago the Microsoft developer community didn\u2019t have [Microsoft Graph Toolkit (MGT)][1] \ud83d\ude31. Fast forward to today, Microsoft Graph now has millions of calls a month through the Microsoft Graph Toolkit and continue to grow month over month. We could not have done it without this creative, collaborative, and amazing community and our partners\u2019 help!<\/p>\n<p>We first introduced Microsoft Graph Toolkit v1 back in September 2019. Since then, we took many feature requests and inspiration from our fans. Today, we are excited to share with you some wonderful new features that are coming to Microsoft Graph Toolkit v2, just a year later. If you would like to try it out, we have a [preview version][2] now. You can install today by running `npm i @microsoft\/mgt@next` in your terminal.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-content\/uploads\/sites\/61\/2021\/02\/meme-justDoIt.jpg\"><img decoding=\"async\" class=\"alignnone size-medium wp-image-227\" src=\"https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-content\/uploads\/sites\/61\/2021\/02\/meme-justDoIt-300x200.jpg\" alt=\"Image meme justDoIt\" width=\"300\" height=\"200\" srcset=\"https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-content\/uploads\/sites\/61\/2021\/02\/meme-justDoIt-300x200.jpg 300w, https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-content\/uploads\/sites\/61\/2021\/02\/meme-justDoIt.jpg 750w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>## Some exciting new features!<\/p>\n<p>### \ud83c\udd95 mgt-person-card [issue #528][3]<\/p>\n<p>Our redesign of Person Card presents many new sections of information centered around the person you are interested in connecting with. We kept the functionalities that allows you to email or send a Microsoft Teams chat directly from the card. We added new sections to show organization information, existing email threads that you both participated in, files you both have access to, and even skills and experiences the person has from the new [Profile API][4]! We are now on to the next step to make the Person Card extensible. So that you can add your own sections and additional information you would like to present.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-content\/uploads\/sites\/61\/2021\/02\/mgt-person-card.png\"><img decoding=\"async\" class=\"alignnone size-large wp-image-228\" src=\"https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-content\/uploads\/sites\/61\/2021\/02\/mgt-person-card-1024x512.png\" alt=\"Image mgt person card\" width=\"640\" height=\"320\" srcset=\"https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-content\/uploads\/sites\/61\/2021\/02\/mgt-person-card-1024x512.png 1024w, https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-content\/uploads\/sites\/61\/2021\/02\/mgt-person-card-300x150.png 300w, https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-content\/uploads\/sites\/61\/2021\/02\/mgt-person-card-768x384.png 768w, https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-content\/uploads\/sites\/61\/2021\/02\/mgt-person-card-1536x768.png 1536w, https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-content\/uploads\/sites\/61\/2021\/02\/mgt-person-card-2048x1024.png 2048w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>You can add the `mgt-person` and `mgt-person-card` components by including the following in your HTML: `&lt;mgt-person person-query=&#8221;me&#8221; view=&#8221;twoLines&#8221; person-card=&#8221;hover&#8221;&gt;&lt;\/mgt-person&gt;`<\/p>\n<p>### \ud83c\udf1a Dark theme<\/p>\n<p>What if your application is built with a dark theme? With v1 you would need to tweak each CSS custom property available for each component. Now you would be able to simply apply `class=\u201dmgt-dark\u201d` to the desired section of your HTML page. We will handle switching between light theme and dark theme for you! We have `mgt-people-picker` component with dark theme available in the preview package. But I will provide some examples below as how you can configure theming with different options.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-content\/uploads\/sites\/61\/2021\/02\/dark-theme.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-224\" src=\"https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-content\/uploads\/sites\/61\/2021\/02\/dark-theme.png\" alt=\"Image dark theme\" width=\"901\" height=\"512\" srcset=\"https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-content\/uploads\/sites\/61\/2021\/02\/dark-theme.png 901w, https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-content\/uploads\/sites\/61\/2021\/02\/dark-theme-300x170.png 300w, https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-content\/uploads\/sites\/61\/2021\/02\/dark-theme-768x436.png 768w\" sizes=\"(max-width: 901px) 100vw, 901px\" \/><\/a><\/p>\n<pre><code class=\"TypeScript\"><\/code><\/pre>\n<p>**Example &#8211; regional theme**<\/p>\n<pre><code class=\"TypeScript\"><\/code><\/pre>\n<p>&lt;div class=&#8221;mgt-light&#8221;&gt;\n&lt;header class=&#8221;mgt-dark&#8221;&gt;\n\/\/ login will have dark theme\n&lt;mgt-login&gt;&lt;\/mgt-login&gt;\n&lt;\/header&gt;\n&lt;article&gt;\n\/\/ agenda will have light theme\n&lt;mgt-agenda&gt;&lt;\/mgt-agenda&gt;\n&lt;\/article&gt;\n&lt;\/div&gt;<\/p>\n<pre><code class=\"TypeScript\"><\/code><\/pre>\n<p>**Example &#8211; global theme**<\/p>\n<pre><code class=\"TypeScript\"><\/code><\/pre>\n<p>&lt;body class=&#8221;mgt-light&#8221;&gt;\n\/\/ everything will be light themed\n&lt;header&gt;&lt;mgt-login&gt;&lt;\/mgt-login&gt;&lt;\/header&gt;\n&lt;article&gt;&lt;mgt-agenda&gt;&lt;\/mgt-agend&gt;&lt;\/article&gt;\n&lt;footer&gt;&lt;\/footer&gt;\n&lt;\/body&gt;<\/p>\n<pre><code class=\"TypeScript\"><\/code><\/pre>\n<p>**Example &#8211; per component theme**<\/p>\n<pre><code class=\"TypeScript\"><\/code><\/pre>\n<p>&lt;mgt-login class=&#8221;mgt-dark&#8221;&gt;&lt;\/mgt-login&gt;<\/p>\n<pre><code class=\"TypeScript\">\r\n\r\n**Example - customized theming**\r\n    .custom {\r\n        --input-background-color: $custom-background-color;\r\n        --input-border: $custom-input-border;\r\n    }\r\n\r\n**Example - Modify specific colors in a theme**\r\n\r\n\r\n    .custom { \r\n        --input-background-color: $custom-background-color;\r\n    }\r\n    <\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>### \ud83d\uddc3 Caching of Microsoft Graph calls [issue #221][6]<\/p>\n<p>Prior to v2, each component calls Microsoft Graph even if sometimes the information retrieved is the same. Think of getting a list of people to display in `mgt-people` and then showing subsets of these people in `mgt-agenda` for different meetings. The caching feature creates an optional and configurable service to cache common graph requests. This will improve the loading performance to help you create a pleasant user experience!<\/p>\n<p>To configure cache, you will need to understand the static class `CacheService.config` object:<\/p>\n<pre><code class=\"TypeScript\">let config = {\r\n  defaultInvalidationPeriod: number,\r\n  isEnabled: boolean,\r\n  people: {\r\n    invalidationPeriod: number,\r\n    isEnabled: boolean\r\n  },\r\n  photos: {\r\n    invalidationPeriod: number,\r\n    isEnabled: boolean\r\n  },\r\n  users: {\r\n    invalidationPeriod: number,\r\n    isEnabled: boolean\r\n  }\r\n};\r\n<\/code><\/pre>\n<p>You can change the cache config as below:<\/p>\n<pre><code class=\"TypeScript\">import { CacheService } from '@microsoft\/mgt';\r\n\r\nCacheService.config.users.isEnabled = false;\r\nCacheService.config.photos.invalidationPeriod: 3600000; \/\/ 1 hour in milliseconds\r\n<\/code><\/pre>\n<p>And here is a comparasion of load time in the same view of an app before and after cache implementation:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-content\/uploads\/sites\/61\/2021\/02\/cache.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-223\" src=\"https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-content\/uploads\/sites\/61\/2021\/02\/cache.png\" alt=\"Image cache\" width=\"2500\" height=\"1018\" srcset=\"https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-content\/uploads\/sites\/61\/2021\/02\/cache.png 2500w, https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-content\/uploads\/sites\/61\/2021\/02\/cache-300x122.png 300w, https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-content\/uploads\/sites\/61\/2021\/02\/cache-1024x417.png 1024w, https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-content\/uploads\/sites\/61\/2021\/02\/cache-768x313.png 768w, https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-content\/uploads\/sites\/61\/2021\/02\/cache-1536x625.png 1536w, https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-content\/uploads\/sites\/61\/2021\/02\/cache-2048x834.png 2048w\" sizes=\"(max-width: 2500px) 100vw, 2500px\" \/><\/a><\/p>\n<p>The overall goal of Microsoft Graph Toolkit team has always been providing the best developer experience possible! A lot of you asked us to make it easier to include MGT components in your React projects. So we created `@microsoft\/mgt-react` package! The library wraps all MGT components and exports them as React components. Try it out today with `npm install @microsoft\/mgt-react`! You can learn more about how to use `@microsoft\/mgt-react` with the [README][8].<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-content\/uploads\/sites\/61\/2021\/02\/meme-aLot.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-225\" src=\"https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-content\/uploads\/sites\/61\/2021\/02\/meme-aLot.jpg\" alt=\"Image meme aLot\" width=\"620\" height=\"464\" srcset=\"https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-content\/uploads\/sites\/61\/2021\/02\/meme-aLot.jpg 620w, https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-content\/uploads\/sites\/61\/2021\/02\/meme-aLot-300x225.jpg 300w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><\/a><\/p>\n<p>## What else is coming?<\/p>\n<p>I started this article thinking it will only be 1 or 2 pages because I wanted to simply highlight a few of these new things. But as I go through the list, I realized that they are all exciting and unique in their own ways. I can\u2019t run through all of them in this post and will have to save the rest of them for the official release announcement. But you can find out more about them by trying out the preview package yourselves \ud83d\ude09. So, here is the rest of the running list of v2 features: &#8211; Package split: mgt-element, mgt, mgt-react &#8211; New mgt-todo component &#8211; Localization helper &#8211; RTL support &#8211; Person Card templating and configuration<\/p>\n<p>## What\u2019s next?<\/p>\n<p>We know there are some big changes in v2, and we want to make sure to take extra care to not break the existing applications that use Microsoft Graph Toolkit, especially in production. For this reason, we really need your help today! Give us feedback on the preview package. Log bugs you find and create issues in our repo. We \u2764\ufe0fLOVE\u2764 community contributions. So much we will send you some interesting Microsoft Graph swags if you help us with any issues with tag \u2018help wanted\u2019 or \u2018good first issue\u2019. You can find a lot of these issues in this project board &#8211; [Community Love][9].<\/p>\n<p>&lt;img src=&#8221;https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-content\/uploads\/sites\/61\/2021\/02\/meme-feedback.jpg&#8221; width=&#8221;400&#8243; \/&gt;<\/p>\n<p>If you are not tired of reading blog articles yet, here is an entire series of [A Lap around Microsoft Graph Toolkit][10]. Our team worked with some of our fabulous Microsoft MVPs to walk you through all the moving parts of Microsoft Graph Toolkit step by step.<\/p>\n<p>If you are interested in learning how to get started with Microsoft Graph Toolkit with a specific type of platform (Teams tab \/ SharePoint Web Part) or web technology framework (React \/ Angular) in mind, you can check out our [brand new get-started guides][11]!<\/p>\n<p>## Stay tuned!<\/p>\n<p>Let us know what topics are of interest to you. And stay tuned with more news and releases coming from our team! \ud83e\udd70<\/p>\n<p>[1]: https:\/\/github.com\/microsoftgraph\/microsoft-graph-toolkit\n[2]: https:\/\/github.com\/microsoftgraph\/microsoft-graph-toolkit\/releases\/tag\/v2.0.0-preview.3\n[3]: https:\/\/github.com\/microsoftgraph\/microsoft-graph-toolkit\/issues\/528\n[4]: https:\/\/docs.microsoft.com\/en-us\/graph\/api\/resources\/profile?view=graph-rest-beta\n[5]: https:\/\/devblogs.microsoft.com\/pax-graph\/wp-content\/uploads\/sites\/62\/2020\/10\/mgt-person-card.png\n[6]: https:\/\/github.com\/microsoftgraph\/microsoft-graph-toolkit\/issues\/221\n[7]: https:\/\/devblogs.microsoft.com\/pax-graph\/wp-content\/uploads\/sites\/62\/2020\/10\/cache.png\n[8]: https:\/\/github.com\/microsoftgraph\/microsoft-graph-toolkit\/blob\/main\/packages\/mgt-react\/readme.md\n[9]: https:\/\/github.com\/microsoftgraph\/microsoft-graph-toolkit\/projects\/29\n[10]: https:\/\/developer.microsoft.com\/en-us\/graph\/blogs\/announcing-a-lap-around-microsoft-graph-toolkit-blog-series\/\n[11]: https:\/\/docs.microsoft.com\/en-us\/graph\/toolkit\/get-started\/overview<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this post, we introduce you to some exciting new features that is coming to Microsoft Graph Toolkit v2!<\/p>\n","protected":false},"author":41911,"featured_media":1176,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25,26,27,28],"class_list":["post-222","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ifdef-windows","tag-mgt","tag-microsoft-graph","tag-microsoft-graph-toolkit","tag-web"],"acf":[],"blog_post_summary":"<p>In this post, we introduce you to some exciting new features that is coming to Microsoft Graph Toolkit v2!<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-json\/wp\/v2\/posts\/222","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-json\/wp\/v2\/users\/41911"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-json\/wp\/v2\/comments?post=222"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-json\/wp\/v2\/posts\/222\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-json\/wp\/v2\/media\/1176"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-json\/wp\/v2\/media?parent=222"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-json\/wp\/v2\/categories?post=222"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/ifdef-windows\/wp-json\/wp\/v2\/tags?post=222"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}