Is there a way to load every label data and every SObject description data using only Javascript without any Apex Server-side code?
How do I import * from @salesforce/schema or @salesforce/label?
I am looking for a way to get all labels or all SObject describe information details to retrieve in LWC at once.
I can see that such syntax is provided by ES6 and is used widely by Salesforce itself, however, it is not possible to use the following syntax in LWC:
import * as schema from '@salesforce/schema'
import * as label from '@salesforce/label'
or this syntax
import {label, schema} from '@salesforce';
since both versions generate error
LWC1512: Missing resource value for @salesforce"
or
LWC1512: Missing resource value for @salesforce/label
Is there a way to load every label data and every SObject description data using only Javascript without any Apex Server-side code?
By the way, if we look as Salesforce Playground we could notice that
the same syntax is used to import everything from lwc
import * as Engine from 'lwc';
however, if we try to insert such line into any of Lightning Web Component, we would receive the following error
LWC1001: Invalid import. Namespace imports are not allowed on "lwc",
instead use named imports "import { LightningElement } from 'lwc'"
or
LWC1517: Invalid LWC import
Best Answer
Everything in LWC which is imported and Exported is a ES6 module.
As this is basically es6 and not just LWC, I tried searching
import all from es6
.Surprisingly, there are many results, I tried a solution from most accepted and most voted answer that suggested exporting * first and then importing it in new component.
My code which exports all lables in
AllLables
modulewhen I try saving it, I get this error:
Apparently, even if there is the way in ES6, SF is intentionally blocking it, probably for the same reason it does not allow
SELECT * in SOQL
You have to use Apex :(