Gathering detailed insights and metrics for salesforce-graphql-helper
Gathering detailed insights and metrics for salesforce-graphql-helper
Gathering detailed insights and metrics for salesforce-graphql-helper
Gathering detailed insights and metrics for salesforce-graphql-helper
npm install salesforce-graphql-helper
Typescript
Module System
Node Version
NPM Version
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
2
1
Salesforce GraphQL API client for browsers and Node with functionality to dynamically, quickly and easily create Salesforce GraphQL queries.
Use the Node package manager npm to install Salesforce GraphQL Helper.
1npm install salesforce-graphql-helper
SALESFORCE_ACCESS_TOKEN
that stores a valid Salesforce access token that will be used for authentication.SALESFORCE_API_URL
that stores your Salesforce API URL (e,g. https://MyDomainName.my.salesforce.com/services/data/v55.0
).Dynamically, quickly and easily create and invoke Salesforce GraphQL queries without worrying about syntax.
Query field values from root object.
1import { GraphQlHelper, RootSObject } from "salesforce-graphql-helper"; 2 3(async function start() { 4 const queryHelper = new GraphQlHelper( 5 new RootSObject("Account").addField("Id").addField("Name") 6 ); 7 const response = await queryHelper.query(); 8})();
Query field values from multiple root objects.
1import { GraphQlHelper, RootSObject } from "salesforce-graphql-helper"; 2 3(async function start() { 4 const queryHelper = new GraphQlHelper(); 5 const account = new RootSObject("Account") 6 .addField("Id") 7 .addField("Name") 8 .addFilter({ Name: { like: "Test%" } }); 9 queryHelper.addRootObject(account); 10 queryHelper.addRootObject( 11 new RootSObject("Contact").addField("Id").addField("Name") 12 ); 13 const response = await queryHelper.query(); 14})();
Query field values from root object as well as field values from parent objects.
1import { GraphQlHelper, RootSObject, ParentSObject } from "salesforce-graphql-helper"; 2 3(async function start() { 4 const queryHelper = new GraphQlHelper( 5 new RootSObject("Contact") 6 .addField("Id") 7 .addField("Name") 8 .addParentSObject(new ParentSObject("Account").addField("Name")) 9 ); 10 const response = await queryHelper.query(); 11})();
Query field values from root object as well as field values from child objects. Child relationships may only be requested as direct descendants of the root object type. You can't query fields from a child relationship pertaining to a parent of the root object.
1import { GraphQlHelper, RootSObject, ChildSObject } from "salesforce-graphql-helper"; 2 3(async function start() { 4 const queryHelper = new GraphQlHelper( 5 new RootSObject("Account") 6 .addField("Id") 7 .addField("Name") 8 .addChildSObject(new ChildSObject("Contacts").addField("Name")) 9 ); 10 const response = await queryHelper.query(); 11})();
Set the where
argument and filter type value (see the Filtering
section of the GraphQL docs).
1import { GraphQlHelper, RootSObject } from "salesforce-graphql-helper"; 2 3(async function start() { 4 const queryHelper = new GraphQlHelper( 5 new RootSObject("Account") 6 .addField("Id") 7 .addField("Name") 8 .addFilter({ Name: { like: "Test%" } }) 9 ); 10 const response = await queryHelper.query(); 11})();
Set the orderBy
argument and OrderBy type value (see the Ordering
section of the GraphQL docs).
1import { GraphQlHelper, RootSObject } from "salesforce-graphql-helper"; 2 3(async function start() { 4 const queryHelper = new GraphQlHelper( 5 new RootSObject("Account") 6 .addField("Id") 7 .addField("Name") 8 .setOrder("Name", "ASC") 9 ); 10 const response = await queryHelper.query(); 11})();
Example portraying a combination GraphQlHelper
functionality.
1import { GraphQlHelper, RootSObject, ParentSObject, ChildSObject } from "salesforce-graphql-helper"; 2 3(async function start() { 4 const queryHelper = new GraphQlHelper( 5 new RootSObject("Account") 6 .addFields(["Id", "Name"]) 7 .addFilter({ Name: { like: "Test%" } }) 8 .setOrder("Name", "ASC") 9 .addParentSObject(new ParentSObject("Parent").addField("Name")) 10 .addChildSObject( 11 new ChildSObject("Contacts") 12 .addFields(["Id", "Name"]) 13 .addParentSObject(new ParentSObject("CreatedBy").addField("Name")) 14 ) 15 ); 16 const response = await queryHelper.query(); 17})();
Invoke a Salesforce GraphQL query as a string and optionally pass filters as a variable.
1import { query } from "salesforce-graphql-helper"; 2 3(async function start() { 4 const queryString = ` 5 query accounts { 6 uiapi { 7 query { 8 Account { 9 edges { 10 node { 11 Id 12 Name { 13 value 14 } 15 } 16 } 17 } 18 } 19 } 20 } 21 `; 22 23 const response = await query(queryString); 24})();
1import { query } from "salesforce-graphql-helper"; 2(async function start() { 3 const queryString = ` 4 query accountsWithFilter($where: Account_Filter) { 5 uiapi { 6 query { 7 Account(where: $where) { 8 edges { 9 node { 10 Id 11 Name { 12 value 13 } 14 } 15 } 16 } 17 } 18 } 19 } 20 `; 21 const accountNameFilter = { Name: { like: "Test%" } }; 22 const response = await query(queryString, accountNameFilter); 23})();
This project is licensed under the GNU General Public License v3.0 - see the LICENSE.md file for details.
No vulnerabilities found.
No security vulnerabilities found.