accessing-webapp-data
Installation
SKILL.md
Salesforce Data Access
Guidance for accessing Salesforce data from web apps. All Salesforce data fetches MUST use the Data SDK (@salesforce/sdk-data). The SDK provides authentication, CSRF handling, and correct base URL resolution — direct fetch or axios calls bypass these and are not allowed.
Mandatory: Use the Data SDK
Every Salesforce data fetch must go through the Data SDK. Obtain it via
createDataSDK(), then usesdk.graphql?.()orsdk.fetch?.(). Never callfetch()oraxiosdirectly for Salesforce endpoints.
Optional Chaining and Graceful Handling
Always use optional chaining when calling sdk.graphql or sdk.fetch — these methods may be undefined in some surfaces (e.g., Salesforce ACC, MCP Apps). Handle the case where they are not available gracefully:
const sdk = await createDataSDK();
// ✅ Use optional chaining
const response = await sdk.graphql?.(query);