microsoft-graph-toolkit
microsoft-graph-toolkit copied to clipboard
Can this document be made more clear?
https://docs.microsoft.com/en-us/graph/toolkit/get-started/build-a-sharepoint-web-part#deploy-the-microsoft-graph-toolkit-sharepoint-framework-package
This talks about deploying Framework packages beforehand, tenant wide
Quesitons are
- Is this only needed if we use React component? (I could make it work without deploying with Non-React SPFx solution)
- Is there a another way to achieve this with React , withut doing tenant wide deployment? Tenant admin are not very interested in deploying a webpart tenant wide on all site collections
Hello rohit404404, thank you for opening an issue with us!
I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌
- You need the MGT SPFx package with all frameworks not just React
- Unfortunately not. The problem is that each web part is independent and if it tries to instantiate MGT on the page, it could be that it will collide with other web part trying to do the same. That is why we centralized it in a separate package. The MGT SPFx package contains a library component and not a web part, so after deploying it, there is nothing visible to users and it's just a building block available to developers working with MGT in SPFx.
Does this clarify it?
@waldekmastykarz Thank you for your prompt response. Appreciate you taking time in answering this.
I checked version of this document which had mentioned installing @microsft/mgt package. So, to get around our tenant admins, I installed just mgt package and my solution started working. (in both React and No JS framework, as u said)
Question is
- What am i losing by not installing mgt-spfx? My understadning is, I cannot have two webparts on same page using Graph toolkit, unless
- its tenant wide deployed
- and mgt-spfx package is included
- So if I have single webpart on the page referring MGT with just mgt package, i should not have any issue.
- If I add mgt-spfx in app-catalog and just install on my site collection , instead of Tenant wide. isnt this supported scenario? It did not work for me. (I do understand cenrtrally deployed mgt-spfx package is much better. However, we know tenant admins. They always start with not trusting anything developer proposes and then developer needs to prove how its not a component causing security issue)
What am i losing by not installing mgt-spfx? My understadning is, I cannot have two webparts on same page using Graph toolkit
Correct. By default, each web part/extension using MGT will try to register MGT with custom web components. The first registration will come through, but all subsequent registrations will fail. To avoid this, we published the mgt-spfx package which is an SPFx library and which does the custom component registrations centrally and just once. That way, no matter how many solutions you use, you don't need to worry about collisions.
So if I have single webpart on the page referring MGT with just mgt package, i should not have any issue.
Theoretically, yes. The problem is that pages is SharePoint are created by users and not developers. Users can add any web parts to page so unless you'd hide web parts using MGT from the toolbox, there is a chance that someone might add multiple web parts using MGT to the page, breaking that page. That's why we recommend to use the mgt-spfx package whenever you use MGT in your solutions.
If I add mgt-spfx in app-catalog and just install on my site collection , instead of Tenant wide. isnt this supported scenario? It did not work for me
So that's interesting. While I haven't seen any specific guidance around SPFx library packages to have to be installed and deployed globally, it would be good to verify this with the SPFx team to see if this is intended to work or not. Just to check: have you both added the mgt-spfx package to the site collection app catalog and installed in the site?
However, we know tenant admins. They always start with not trusting anything developer proposes and then developer needs to prove how its not a component causing security issue
Do your admins have specific concerns regarding mgt-spfx that we could clarify?
@waldekmastykarz Thank you for confirming my understanding.
About mgt-spfx package deployment. When I add/deploy mgt-spfx package in tenant app catalog , I get below prompt. Tenant admins are ok with deploying this , Just not comfortable clicking that little checkbox , which makes it available to all site collections.
Now, i did a test by
- deploying the package centrally and kept this checkbox unchecked.
- Then i installed this package in my specific site collection (i.e. add an app)
- Then installed my custom app (which uses toolkit)
- Added custom app on my page and it gave error (Missing component)
- I went back and readded spfx-mgt package in central app catalog. However, this time I checked the little checkbox. Which installed it in every site collection of my test tenant
- Went back to my page and refresh the page, webpart loaded successfully.
I really cannot rule out caching issue here. So not really sure if checking that box made it work or it was just caching. However, I tried this twice with same result and checking the box seems to make a difference.
Tenant admins have special concern about checking the box, which they think is as good as running the code on all site collections. (Even thugh there isnt any hidden code)
It will be great to know if its sufficient to ,
- Deploy mgt-spfx and custom app to central app catalog (without checkbox)
- Add both these apps to respective intended site collection
Apologies if i repeated some of the statement.
To answer your question, I do not have App catalog enable on site collection. I am deploying everything centrally. Now that you ahve mentioned it, may be I can try enabling Site colleciton app catalog and test this.
Thank you for the additional information. Let me see if I can find out anything internally about any possible constraints related to using library components
Our engineering confirmed that adding an .sppkg with a library component in the tenant app catalog and installing it in a single site should work. Let me check if I can reproduce what you're seeing and get back to you.
@waldekmastykarz Thank you Waldek. Now that we have confirmation, let me try that as well to rule out Caching.
This is embarassing. I have donwloaded package from Release 2.2 . https://github.com/microsoftgraph/microsoft-graph-toolkit/releases/download/v2.2.0/mgt-spfx-2.2.0.sppkg
- Uploaded this to my Tenant app catalog.
- Deployed it (Without selecting Checkbox)
- Went to one of the site colelction and click on Add an app.
- Select app "mgt-spfx-client-side-solution"
- Get redirected to site content page. Where i see app is getting added.
- I refresh after 5 mins and its still greyed out.
- Switch to classic mode and it shows error. Clicked on retry, no use.
Repeated all these steps on another tenant . Same behaviour.
What am i missing here. I feel stupid that I cannot get package installed on site collection. These are groups sites I am trying on , if that makes a difference.
I am global admin on both tenants.
I'm seeing the same error. Let me see if I can find out anything more about it.
I've been able to reproduce the issue with a plain SPFx library as well, so it's not something related specifically to MGT. The SPFx team is looking into it.
Thank you VERY MUCH for the finding and the further investigation. We confirmed that this is, indeed, a bug in our provisioning system. A Fix has been issued as per last week and it's currently rolling in production. it will take (roughly) a couple of week before it reaches 100% of all our production tenants.
@lucabandMSFT Any way to identify if my tenant has receved this fix? Else, of course I can keep trying by installing SPFX based solution.
@lucabandMSFT Tried on two different tenant that allows first release. Still unable to install SPFX pachage on site.
I don't know if this is at all related, but I have one tenant using web parts with MGT, and they are returning this error.
We are using these web parts on 3 other tenants perfectly fine, just one affected tenant. 2.21 of the library is deployed at the tenant app catalog, available to all sites checked.
[SPLoaderError.loadComponentError]:
Failed to load component "02a39121-3d08-4746-8ee6-2baa39c61dda" (XXXXXXWebPart). Original error: Failed to load component dependency "02a39121-3d08-4746-8ee6-2baa39c61dda" from component "XXXXXXWebPart" (Failed to load component "78b11c7d-7ca8-47cb-a93c-d3beabb519a1" (MgtSpfxLibrary). Original error: loadComponent() returned an empty object for component "78b11c7d-7ca8-47cb-a93c-d3beabb519a1" (MgtSpfxLibrary).). Original error: {3}
INNERERROR:
Failed to load component dependency "02a39121-3d08-4746-8ee6-2baa39c61dda" from component "XXXXXXWebPart" (Failed to load component "78b11c7d-7ca8-47cb-a93c-d3beabb519a1" (MgtSpfxLibrary). Original error: loadComponent() returned an empty object for component "78b11c7d-7ca8-47cb-a93c-d3beabb519a1" (MgtSpfxLibrary).). Original error: {3}
CALLSTACK:
Error
at t [as constructor] (https://modernb.akamai.odsp.cdn.office.net/files/sp-client/sp-pages-assembly_en-us_aeb533d29e5a407db9720a55c4994f87.js:65:19844)
at new t (https://modernb.akamai.odsp.cdn.office.net/files/sp-client/sp-pages-assembly_en-us_aeb533d29e5a407db9720a55c4994f87.js:65:169908)
at Function.e.buildErrorWithVerboseLog (https://modernb.akamai.odsp.cdn.office.net/files/sp-client/sp-pages-assembly_en-us_aeb533d29e5a407db9720a55c4994f87.js:65:207322)
at Function.e.buildLoadComponentError (https://modernb.akamai.odsp.cdn.office.net/files/sp-client/sp-pages-assembly_en-us_aeb533d29e5a407db9720a55c4994f87.js:65:203367)
at https://modernb.akamai.odsp.cdn.office.net/files/sp-client/chunk.systemjs-component-loader_en-us_0eba02f0141d373ece15.js:1:11895
EDIT: SOMETIMES, the web part throws this, again unsure if related:
Something went wrong
If the problem persists, contact the site administrator and give them the information in Technical Details.
TECHNICAL DETAILS
[SPLoaderError.loadComponentError]:
Failed to load component "412fae60-e348-490e-8c8d-c5d03d2f2351" (XXXXXXWebPart). Original error: Failed to load component dependency "412fae60-e348-490e-8c8d-c5d03d2f2351" from component "XXXXXXWebPart" (Failed to load component "78b11c7d-7ca8-47cb-a93c-d3beabb519a1" (MgtSpfxLibrary). Original error: Failed to load entry point from component "78b11c7d-7ca8-47cb-a93c-d3beabb519a1" (MgtSpfxLibrary). Original error: Failed to execute 'define' on 'CustomElementRegistry': the name "mgt-mock-provider" has already been used with this registry). Original error: {3}
INNERERROR:
Failed to load component dependency "412fae60-e348-490e-8c8d-c5d03d2f2351" from component "XXXXXXWebPart" (Failed to load component "78b11c7d-7ca8-47cb-a93c-d3beabb519a1" (MgtSpfxLibrary). Original error: Failed to load entry point from component "78b11c7d-7ca8-47cb-a93c-d3beabb519a1" (MgtSpfxLibrary). Original error: Failed to execute 'define' on 'CustomElementRegistry': the name "mgt-mock-provider" has already been used with this registry). Original error: {3}
CALLSTACK:
Error
at t [as constructor] (https://modernb.akamai.odsp.cdn.office.net/files/sp-client/sp-pages-assembly_en-us_aeb533d29e5a407db9720a55c4994f87.js:65:19844)
at new t (https://modernb.akamai.odsp.cdn.office.net/files/sp-client/sp-pages-assembly_en-us_aeb533d29e5a407db9720a55c4994f87.js:65:169908)
at Function.e.buildErrorWithVerboseLog (https://modernb.akamai.odsp.cdn.office.net/files/sp-client/sp-pages-assembly_en-us_aeb533d29e5a407db9720a55c4994f87.js:65:207322)
at Function.e.buildLoadComponentError (https://modernb.akamai.odsp.cdn.office.net/files/sp-client/sp-pages-assembly_en-us_aeb533d29e5a407db9720a55c4994f87.js:65:203367)
at https://modernb.akamai.odsp.cdn.office.net/files/sp-client/chunk.systemjs-component-loader_en-us_0eba02f0141d373ece15.js:1:11895
EDIT 2: There was another third party component interfering with ours. I noticed it as the console had telemetry information about the attempts to load MGT - but the telemetry was being written from that third party component's code and nothing to do with our code or the SPFX runtime.
Used this line to reproduce reliably the errors:
window._spComponentLoader.loadComponentById('78b11c7d-7ca8-47cb-a93c-d3beabb519a1')
@jimmywim Thats strange. I never had issue , if I SPFX package is deployed tenant wide (seelct that little checkbox while deploying). This perticualr bug is, when you do not select checkbox and then try to manaully install SPFX package app on respective site , which doesnt install it. I will test this agian, since @lucabandMSFT said they have released fix. Not sure if that affected.
@rohit404404 I always see the following: when loading a page first time with my webpart on it:
Failed to load component dependency "d136bd92-9977-46ed-a2f2-3ce2c0ee91d8" from component "xxxxxWebPart" (Failed to load component "78b11c7d-7ca8-47cb-a93c-d3beabb519a1" (MgtSpfxLibrary). Original error: loadComponent() returned an empty object for component "78b11c7d-7ca8-47cb-a93c-d3beabb519a1" (MgtSpfxLibrary).). Original error: {3} CALLSTACK: Error at t [as constructor] (https://res-1.cdn.office.net/files/sp-client/sp-pages-assembly_en-us_d0d485340a24e21451dae345f9f59a12.js:70:214899) at new t (https://res-1.cdn.office.net/files/sp-client/sp-pages-assembly_en-us_d0d485340a24e21451dae345f9f59a12.js:71:7680) at e.buildErrorWithVerboseLog (https://res-1.cdn.office.net/files/sp-client/sp-pages-assembly_en-us_d0d485340a24e21451dae345f9f59a12.js:71:44944) at e.buildLoadComponentError (https://res-1.cdn.office.net/files/sp-client/sp-pages-assembly_en-us_d0d485340a24e21451dae345f9f59a12.js:71:41035) at https://res-1.cdn.office.net/files/sp-client/chunk.systemjs-component-loader_en-us_2b7c6d12ca54d8302d17.js:1:6012
I tried as described above mgt-spfx-2.4.0.sppkg in:
-
the global app catalog with "Make this solution available to all sites in the organization".
-
the global app catalog without "Make this solution available to all sites in the organization", mgt-spfx-client-side-solution. The app has been manually added to the site without any issues.
-
the site app catalog without "Make this solution available to all sites in the organization", mgt-spfx-client-side-solution. The app has been manually added to the site without any issues.
My webpart solution using mgt was deployed to a site app catalog and added as an app without any issues.
Either try has the same result. Any hint on this?
I'm going to close this issue as it is stale and our documentation has evolved a lot since this was raised.
If there are still issues please do raise new issues