Accessing SharePoint data with the Graph API and the SharePoint Framework
The Microsoft Graph API’s resources can also be accessed within the SharePoint Framework for creating solutions to consume, update, and create new data for Microsoft Cloud services. The SharePoint Framework supplies a ready-made HTTP client, which handles user authentication and permissions automatically, to access the Graph API’s resources. Calling Graph from the SharePoint Framework is simple; just use an import clause to introduce the MSGraphClientV3 client to the solution:
import {MSGraphClientV3} from '@microsoft/sp-http';
And then it can be used to call the Graph API:
this.context.msGraphClientFactory.getClient("3").then((client:MSGraphClientV3): void=>{client.api("/me").get((error, response:any, rawResponse?:any)=>{ this.userProf.displayName = response.displayName; ...