Skip to content

Microsoft Graph JavaScript SDK V3.0 Upgrade Guide

Roina Atieno Ochieng edited this page May 12, 2021 · 1 revision

Microsoft Graph JavaScript SDK V3 Upgrade Guide

Breaking Changes

Supported Node version and TypeScript update

  • Microsoft Graph JS SDK requires Node.js 10 LTS or higher.
  • Updated to TypeScript 4.x.

LargeFileUploadTask

  • Modified the FileObject interface which now contains the sliceFile function. Learn more LargeFileUploadTask.
  • The FileObject instance passed on creation of the LargeFileUploadTask object should contain the implementation of the sliceFile function.
  • Added new classes FileUpload and StreamUpload implementing the FileObject interface.

Removed timeout option from FetchOptions interface

Update in the package.json entry points.

{
    "main": "lib/src/index.js",
    "module": "lib/es/src/index.js",
    "browser": {
	    "./lib/es/src/index.js": "./lib/es/src/browser/index.js"
    }
}

Removed the graph-es-sdk.js

  • graph-es-sdk.js - the bundled file in ES format will not be shipped anymore as the ES modules are being shipped.
  • graph-js-sdk.js will be shipped as is.

Changed folder paths

  • Files in lib/es have been moved to lib/es/src. The lib folder contains the transpiled src files.
    • The lib contains the ES and CJS modules as follows:
     	lib
     	│
     	└─── src (CJS modules)
     	|
     	│   
     	└─── es 
     	     |___ src (ES modules)
    
  • Range: src/Range changed to src/tasks/FileUploadTask/Range.
  • ImplicitMSALAuthenticationProvider:
    • src/ImplicitMSALAuthenticationProvider changed to src/authentication/msal/ImplicitMSALAuthenticationProvider.
    • Alternatively, ImplicitMSALAuthenticationProvider can be imported or required from @microsoft/microsoft-graph-client/authProviders/msal.
  • MSALAuthenticationProviderOptions:
    • src/MSALAuthenticationProviderOptions changed to src/authentication/msal/MSALAuthenticationProviderOptions.
    • Alternatively, MSALAuthenticationProviderOptions can be imported or required from @microsoft/microsoft-graph-client/authProviders/msal.

Enhancements

Introducing support for @azure/identity TokenCredentials

  • Added a TokenCredentialAuthenticationProvider enabling the use of @azure/identity credential classes for authentication purposes.
  • The TokenCredentialAuthenticationProvider enables server-side authentication using credential classes such as ClientSecretCredential or ClientCertificateCredential.
  • Find the samples on how to use TokenCredentialAuthenticationProvider here - TokenCredentialAuthenticationProvider samples

LargeFileUploadTask

  • Added support for Node.js Stream upload. Learn more LargeFileUploadTask.
  • Added capabilities to track the upload progress using UploadEventHandlers.
  • Resolved a bug to enable large file uploads to Outlook and Print APIs.

Added browser field in package.json.

  • The browser field indicates the entry point for client applications using Microsoft Graph JS SDK library.

Added GraphClientError

  • GraphClientError handles client-side errors encountered within the JavaScript Client SDK whereas, GraphError class should be used to handle errors in the response from the Graph API.

Deprecation

Deprecating ImplicitMSALAuthenticationProvider

Deprecating the sliceFile function of the LargeFileUploadTask class.

  • The sliceFile function has been moved to the FileObject interface.