/headless-app-query-data-salesforce-graphqlapi

This headless application is designed to fetch data from Salesforce using GraphQL API. It facilitates querying Salesforce data without the need for a traditional frontend application. You can use this application to retrieve data from Salesforce and integrate it into various backend processes, microservices, or other apps.

Primary LanguageJavaScript

Headless App Query Data Salesforce GraphQL API

This project aims to provide a headless application that interacts with Salesforce using GraphQL API to query data.

Overview

This headless application is designed to fetch data from Salesforce using GraphQL API. It facilitates querying Salesforce data without the need for a traditional frontend application. You can use this application to retrieve data from Salesforce and integrate it into various backend processes, microservices, or other applications.

Features

  • Queries data from Salesforce using GraphQL API.
  • Provides flexibility in fetching specific data sets based on GraphQL queries.
  • Supports integration with various backend systems and processes.

Getting Started

To get started with the project, follow these steps:

  1. Clone the repository to your local machine:

    git clone https://github.com/tomsouza4/headless-app-query-data-salesforce-graphqlapi.git
  2. Install the required dependencies:

    • Navigate to the project directory
    cd headless-app-query-data-salesforce-graphqlapi
  3. Configure environment variables:(Coming soon, skip to next step)

    • Open the .env file.
    • Update the Salesforce credentials and GraphQL endpoint as per your Salesforce environment.
  4. Run the application:

    npm install
    npm start

5.In Salesforce it is required to configure:

image
  • Create a Connected App
image image

Command line to get the the oauth token on Mac:

  • Optional to format your response in a human readable way:
brew install jq
curl https://YOUR_SERVER_URL/services/oauth2/token -d 'grant_type=client_credentials' -d 'client_id=PASTE_YOUR_CONSUMER_KEY_HERE' -d 'client_secret=PASTE_YOUR_CONSUMER_SECRET_HERE' | jq .access_token | pbcopy

Copy the token after "access_token" something like:

"access_token":"00D8b0000022ug0!AQ8AQGbKIjjkVTHUIcDCYehMqhmqOqc.iKQsKUaDp3zomRfp8kgZjCgJ8TxDlSGOfzwVkjfNGHpCXd_3vtIEkJFPGZSOkOSv"

Paste the content to index.js file under const token variable

 const token = "00D8b0000022ug0!AQ8AQNfmDcCNjlqah6UTK90X7WWdRyFfeOXHuEq2hH3fLLTMvRLZ2B9oP5wbjfxzCs.SxtKu0pcCqSWqKVCg4OvisTbkibhU";
  1. Access the application:

    Once the application is running, go to:

    http://localhost:3000

    or any other URL and port combination you've selected

Usage

To use the application, you can:

  1. Send GraphQL queries to the specified endpoint.
  2. Analyze and process the data fetched from Salesforce based on your requirements.
  3. Integrate the application with other systems or processes as needed.

Sample Output (there is a video below)

ReactAppQueryingSFData.mov

Contributing

Contributions to the project are welcome. If you have any suggestions, improvements, or bug fixes, feel free to open an issue or create a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.