📢 GraphQL API module for Perfex CRM

In today's fast-paced digital environment, the ability to connect and integrate various services and applications is paramount for maximizing efficiency and productivity. Recognizing this need, we developed the GraphQL API Module for Perfex CRM to facilitate seamless third-party connections within the Perfex CRM ecosystem.

The GraphQL Module empowers developers and users to unlock limitless possibilities by enabling them to interact not only with the native tables of the Perfex CRM database but also with custom modules created by third-party authors.


Benefits:

  • Enhanced Flexibility: The module supports querying and mutating data across both native and custom tables, providing users with the flexibility to tailor their interactions with the CRM to meet specific business needs.
  • Streamlined Data Access: With GraphQL's client-specified queries, users can request precisely the data they require in a single request, reducing the number of API calls and optimizing performance.
  • Interoperability: This module fosters better interoperability between Perfex CRM and external applications, enabling businesses to integrate their workflows and automate processes more efficiently.
  • Robust Schema Definition: The strongly typed schema defined by GraphQL allows developers to understand the data structure readily, ensuring that integrations are implemented smoothly and errors are minimized.
  • Support for Real-Time Applications: With support for subscriptions, the module can handle real-time updates, making it ideal for applications that require live data feeds, such as dashboards or reporting tools.

By offering a unified and comprehensive solution for data management, our GraphQL Module not only enhances the capabilities of Perfex CRM but also opens new avenues for third-party integrations, making it an invaluable tool for businesses looking to optimize their CRM experience.



❓ What GraphQL is

GraphQL is a modern query language for APIs and a runtime for executing those queries by leveraging a type system that you define for your data.
Developed by Facebook in 2012 and released as an open-source project in 2015, GraphQL provides a more efficient, powerful, and flexible alternative to the traditional REST API architecture.


Features:

  • Single Endpoint: Unlike REST APIs that require multiple endpoints for different resources, GraphQL operates through a single endpoint. This simplifies the API structure and reduces the overhead of managing multiple routes.
  • Client-Specified Queries: With GraphQL, clients can specify exactly what data they need in their requests. This means that you can request specific fields and nested data in a single query, avoiding the pitfalls of over-fetching or under-fetching data.
  • Strongly Typed Schema: GraphQL APIs are defined by a schema that specifies the types of data that can be queried and the relationships between those types. This strong typing helps in validating queries before they are executed, ensuring that clients only request valid data.
  • Real-time Data with Subscriptions: GraphQL supports real-time updates through subscriptions, allowing clients to receive updates whenever specific events occur in the system. This is particularly useful for applications requiring live data feeds.
  • Introspection: GraphQL APIs allow clients to query the schema itself. This means developers can discover the types, queries, and mutations available in the API, making it easier to understand and use the API effectively.

In summary, GraphQL revolutionizes how APIs are structured and consumed, providing developers with powerful tools to build modern applications that demand flexibility and efficiency in data handling.

👍 GraphQL vs. REST

In the realm of web development, APIs serve as a bridge between different systems, enabling them to communicate effectively.
Two popular architectural styles for building APIs are GraphQL and REST.
While both serve the same fundamental purpose, they have distinct approaches, features, and benefits.

In case you end up in the conclusion that a REST system works better for you, keep in mind that we also provide a REST API module for Perfex, which can be purchased through this link, for those who prefer the this approach.


Data Fetching and Structure


REST:

  • REST APIs expose multiple endpoints, each corresponding to a specific resource (e.g., /users, /orders). To retrieve data, clients often need to make multiple requests to various endpoints.
  • The structure of the response is fixed and can lead to over-fetching or under-fetching of data. For example, a client may receive unnecessary data or may need to request additional endpoints to get all the required information.

GraphQL:

  • GraphQL operates through a single endpoint, where clients can specify exactly what data they need in a single request. This eliminates over-fetching and under-fetching.
  • Clients define their query structure, allowing them to request nested resources and relationships without multiple requests. This flexibility provides a more efficient data retrieval process.


Versioning


REST:

  • As REST APIs evolve, maintaining different versions of the API can become necessary (e.g., v1, v2). This can lead to increased complexity and potential inconsistencies between versions.

GraphQL:

  • GraphQL APIs typically do not require versioning. Instead, they allow clients to request only the fields they need, which means that the API can evolve without breaking existing queries. This leads to a more stable and consistent API experience over time.


Error Handling


REST:

  • REST APIs use standard HTTP status codes to convey the result of API requests. While this is straightforward, it can be limiting, as the status codes provide limited context about errors.

GraphQL:

  • GraphQL provides a more detailed error reporting mechanism. Along with the response, errors can be included in the payload, allowing clients to handle specific issues more effectively and providing clearer insights into what went wrong.


Tooling and Ecosystem


REST:

  • REST has a long history and is widely adopted. As a result, there is a rich ecosystem of tools and libraries that facilitate development, testing, and integration.

GraphQL:

  • GraphQL is relatively newer but has gained rapid popularity. It comes with powerful developer tools, such as GraphiQL and Apollo Client, which enhance the development experience by providing real-time documentation and interactive querying capabilities.


Use Cases and Performance


REST:

  • REST is well-suited for applications that have straightforward resource interactions. It is ideal for scenarios where resources can be represented as distinct entities, such as CRUD operations.

GraphQL:

  • GraphQL shines in applications that require complex data retrieval and relationships, such as social media platforms or data-intensive applications. Its ability to handle complex queries efficiently makes it suitable for modern applications where performance and flexibility are paramount.


Conclusion

Both GraphQL and REST APIs have their strengths and weaknesses, making them suitable for different use cases. When deciding between the two, consider the specific needs of your application, the complexity of your data relationships, and the development experience you wish to provide.

By leveraging the strengths of both technologies, you can create a robust and dynamic environment for your applications.

🌎 GraphQL Support

In recent years, GraphQL has emerged as a powerful tool for APIs, offering developers and businesses an alternative to the traditional REST API model. Its adaptability, efficiency, and growing support across major platforms make it an indispensable component for modern applications, especially when integrating third-party services.

For a customer relationship management (CRM) system that is built on GraphQL, the advantages are clear: flexibility, efficiency, scalability, and seamless integration with external services.

As businesses increasingly rely on APIs to streamline operations and enhance digital experiences, GraphQL's adoption is skyrocketing. Many companies, such as GitHub, Shopify, and Twitter, have fully embraced GraphQL to handle complex data requests across multiple services. This has created a rich ecosystem where third-party applications and platforms now widely support GraphQL.

Here are several key reasons why this widespread support is beneficial for a GraphQL-based CRM:


1. Seamless Integration with Third-Party Services

The ability to integrate with third-party services is crucial for any CRM. From email marketing tools to payment gateways and project management software, businesses often use a combination of services to run their operations. GraphQL’s adaptability means it can work harmoniously with various third-party services that have already adopted the technology. Because of its wide adoption, many third-party services now provide GraphQL endpoints, making integration more seamless and faster.

For example, platforms like Shopify and Stripe offer GraphQL APIs, allowing your CRM to easily pull in or push out customer, transaction, and order data. A CRM built on GraphQL can quickly interact with these services, reducing the complexity of API management and providing a unified data exchange.



3. Reduced Client-Side Complexity

A key pain point for developers working with REST APIs is managing multiple endpoints, each serving different data sets. This often leads to an explosion of HTTP requests on the client side, creating slower applications and increasing maintenance efforts. With GraphQL, a single query can retrieve multiple sets of data from various resources in one round trip to the server, reducing the number of requests needed and simplifying the client-side architecture.

For a CRM like Perfex, this means less complexity in fetching client data, sales metrics, and account activities. Third-party services, such as analytics tools or payment systems, can be seamlessly integrated into one API request. This efficiency is crucial for a modern CRM to handle large data sets, multiple data sources, and heavy usage without slowing down.



4. Scalability and Flexibility

GraphQL offers the flexibility to grow and evolve alongside your business and your clients’ needs. Since GraphQL queries are flexible and can change based on the client’s requirements, this scalability makes it easier to extend your CRM with additional features or integrations without the need to create new endpoints or rewrite existing logic. This can be a huge benefit for CRMs that need to evolve over time to integrate with new third-party services or support new business processes.

A CRM that supports GraphQL can dynamically serve multiple clients with varying needs, ensuring that everyone gets the precise data they need, making it an attractive solution for businesses that demand flexibility and customization.



5. Better Documentation and Tooling

As GraphQL adoption grows, so does the ecosystem surrounding it. GraphQL has robust documentation tools like GraphiQL and Apollo Studio, which make testing and building queries easier for developers. Many third-party services now include built-in GraphQL playgrounds, helping users explore available data and build queries efficiently. These powerful tools improve developer productivity and make it easier to work with APIs, both for internal CRM developers and third-party service providers.

For a GraphQL-based CRM, this means better onboarding experiences for developers, smoother integration with external tools, and more reliable collaboration with third-party platforms. Clear documentation and powerful query testing features improve the developer experience and reduce friction when building custom workflows or integrations.



By leveraging the wide support for GraphQL in modern applications and third-party services, your Perfex CRM becomes more than just a tool for managing customer data!
It evolves into a flexible, high-performance platform capable of interacting with multiple services, delivering real-time insights, and handling complex workflows with ease.

As more businesses shift towards integrating numerous tools and services to enhance their operations, the ability to offer a CRM that embraces GraphQL will give you a significant competitive advantage. With the growing demand for modern, efficient API-driven platforms, a GraphQL-based CRM is the perfect solution for businesses looking to stay ahead of the curve.

⚙️ Installation

Installing and activating this module is a quick and simple process that takes only a few seconds. With just a few clicks, you’ll be able to integrate it seamlessly into your system, allowing you to immediately benefit from its features without delays or complications.

To ensure a smooth experience, we’ve outlined the steps in the following guide for a hassle-free installation and activation process. Following the instructions will guarantee that you complete the setup in no time, avoiding common mistakes that might arise during configuration.

We highly recommend you carefully review each step before proceeding. If at any point you encounter issues, don’t worry! Our support team is ready to assist you. Should any questions arise during the installation or activation, feel free to raise a support ticket through our Support Area.

Our dedicated support department is staffed by experienced operators who are eager to help and will respond as quickly as possible with solutions. Whether it’s a minor question or a significant issue, we’re here to guide you through every step of the process. Rest assured that help is just a click away!

Download

After purchasing and downloading the module package, the next step is to extract the contents of the file you received.

Upon extraction, you will notice two main components: a folder labeled "documentation" and a compressed file named "upload.zip".

The "documentation" folder contains helpful instructions and this readme file, which are designed to guide you through the installation process. However, these files are not required for the actual installation within Perfex CRM. Therefore, we will focus on the essential "upload.zip" file, which contains the core module files.

Extracted Files Example




The "upload.zip" archive contains the complete set of module files that you will need to install the module within your Perfex CRM system.

These files are pre-configured in the proper module format, ensuring smooth integration with Perfex CRM's existing architecture. To proceed, you will need to upload this zip file directly through Perfex CRM's Modules installation section.

Upload.zip Example

Installation Steps

The installation process for this module is designed to be straightforward.

Follow the steps outlined below to install it successfully within your Perfex CRM instance:

  1. First, log in to your Perfex CRM's Admin area. From the main dashboard, navigate to the SETUP menu, and from the drop-down options, select MODULES. This section is where you will manage and install any additional modules.

    Perfex Setup Menu

  2. In the Modules section, you will be prompted to select the module file for installation. Click on the selection prompt and locate the previously extracted upload.zip file. After selecting it, press the INSTALL button to begin the installation process. Perfex CRM will automatically handle the configuration and setup of the module.

    Module Installation Example

Activation

Once the module installation is complete, the final step is to activate the module within your Perfex CRM system.

This process ensures that the module is functional and ready for use:

  1. Locate the newly installed module within the Modules section of your Perfex CRM. Next to the module name, you will see an ACTIVATE button.
    Simply click this button to activate the module.

    Activate Module Example

  2. After pressing ACTIVATE, you will be prompted to enter your License Key to complete the activation. Once entered, you will receive a confirmation message indicating that the module has been successfully activated.

That's it! Your module is now fully installed and activated, ready to enhance the functionality of your Perfex CRM.
You can now begin exploring its features and configuring it to fit your specific needs.

🖧 Data exchange

GraphQL provides a powerful and flexible approach to data exchange in modern applications by allowing clients to interact with server-side data in a streamlined and efficient manner. Unlike traditional APIs, which often require multiple endpoints to perform different operations, GraphQL operates over a single, unified endpoint. This consolidation greatly simplifies the API structure, reducing complexity and allowing developers to focus on the core logic of their application rather than managing various endpoints.

What makes GraphQL particularly effective for data exchange is its ability to dynamically manage interactions between clients and servers. Whether an application needs to fetch large amounts of interconnected data or perform detailed data manipulations, GraphQL ensures that these operations are handled with precision and clarity. The flexibility it offers allows developers to build more interactive and scalable applications, as GraphQL seamlessly adapts to both simple and complex data requirements.

One of the notable features of GraphQL in data exchange is its capacity to reduce unnecessary data transfers. In many systems, it is common to encounter over-fetching (retrieving more data than needed) or under-fetching (needing to make multiple requests to gather all required data). By empowering clients to request exactly what they need, GraphQL minimizes network overhead and accelerates the flow of data between client and server. This efficiency is crucial for modern applications that rely on fast, optimized performance, especially in scenarios where bandwidth is limited or response times are critical.

Furthermore, GraphQL promotes a more intuitive and collaborative workflow between frontend and backend development teams. With its strongly-typed schema and declarative nature, developers can quickly understand the available data structures and relationships, making it easier to create, maintain, and evolve data-driven applications. This transparency helps align team efforts, reducing miscommunications and ensuring smoother development processes over the lifecycle of a project.

Queries

Queries in GraphQL are similar to GET requests in REST APIs, but they offer significantly more flexibility and precision. When a client sends a query, it can specify exactly which fields and related entities it needs, allowing for the retrieval of complex nested data in a single request. This capability is a game-changer for developers, as it streamlines the data-fetching process and enhances the overall performance of applications.

This is particularly useful for applications that need to load multiple related pieces of information, such as a customer profile with their associated orders and preferences, without making several network requests. This results in a more efficient use of network resources and provides a seamless user experience.

In a GraphQL-based system, data is represented as a graph of nodes connected by relationships. Each node in this graph represents an entity, such as a user, product, or order, while each relationship defines how these entities are connected. This interconnected structure enables developers to model complex data interactions naturally and intuitively.

When a query is made, GraphQL’s server-side schema ensures that the request is validated and executed efficiently, delivering only the requested data. This targeted approach minimizes bandwidth usage and accelerates data delivery by reducing unnecessary server processing, ultimately leading to faster response times and a more responsive application.

Mutations

Mutations, on the other hand, allow clients to perform write operations such as creating, updating, or deleting data. While a query is read-only, a mutation directly modifies data on the server, enabling more dynamic interactions with the underlying database. Each mutation for add operations can return the ID, making the data exchange process more efficient, without requiring an additional query.


For example, when creating a new record in a database (such as adding a new client to a CRM), a mutation can not only insert the data but also return the newly created client's ID in a single transaction. This capability streamlines operations, eliminates the need for follow-up requests, and enhances overall efficiency, which are often required in REST-based systems.


Moreover, the structured approach of GraphQL mutations ensures that data integrity is maintained while performing these operations, allowing developers to handle errors gracefully and provide meaningful feedback to users. This level of control over data modifications is essential for applications that require a robust data management strategy.

📝 Usage

Subsections below describe how to use GraphQL queries/mutations for Perfex CRM's native and non-native tables, under a variety of coding languages (the most popular ones according to the often implementation needs of Perfex CRM third party service connections).

It is important to be aware that every request to GraphQL endpoint is secured by a token and thus said, you will need to parse it as a header value to it.
The generated token is created after the initial activation of our module, but you can regenerate it manually.
👉 You can find the installation's token in the settings of the module ( GraphQL -> Token )

The header parameter's key name that you need to parse this token to, needs to be specific, the same way endpoint is.


Header key name:


authtoken


authtoken value:


392187328 (replace it with your installation's token)


GraphQL Endpoint:


yourdomain.com/graphql (replace yourdomain.com with your actual domain)


Depending on the way that you will use GraphQL, you will need to include those data respectively.

To simplify your interactions with the GraphQL API, you can use popular software tools like Postman or Insomnia.
These tools provide a user-friendly interface for making HTTP requests, including support for adding headers easily.

In both Postman and Insomnia, you can specify the authtoken in the headers section of the request settings and the endpoint in the URL settings:


⚪ Postman

  1. Open Postman and create a new request. Use the endpoint in the URL section.
  2. Go to the Headers tab.
  3. Add a new header with the key authtoken and the value as your generated token.

⚪ Insomnia

  1. Create a new request. Use the endpoint in the URL section.
  2. In the Headers tab, add a new header.
  3. Enter authtoken as the key and paste your generated token as the value.

Using these tools will help streamline your testing and integration with the Perfex CRM GraphQL module.


Per coding language / method, queries:



Example using cURL


curl -X POST \
  http://yourdomain.com/graphql \
  -H "Content-Type: application/json" \
  -H "authtoken: YOUR_GENERATED_TOKEN" \
  -d '{
    "query": "{ yourTable { field1 field2 } }"
}'


Example using JavaScript (Fetch API)


fetch('http://yourdomain.com/graphql', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        'authtoken': 'YOUR_GENERATED_TOKEN'
    },
    body: JSON.stringify({
        query: '{ yourTable { field1 field2 } }'
    })
})
.then(response => response.json())
.then(data => console.log(data));


Example using Python (requests library)


import requests

url = 'http://yourdomain.com/graphql'
headers = {
    'Content-Type': 'application/json',
    'authtoken': 'YOUR_GENERATED_TOKEN'
}
query = '{ yourTable { field1 field2 } }'

response = requests.post(url, json={'query': query}, headers=headers)
print(response.json())


Example using PHP (cURL)


$url = 'http://yourdomain.com/graphql';
$headers = [
    'Content-Type: application/json',
    'authtoken: YOUR_GENERATED_TOKEN'
];
$query = '{ yourTable { field1 field2 } }';

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['query' => $query]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

echo $response;


Ensure you replace YOUR_GENERATED_TOKEN with the actual token generated during the module's activation and yourdomain.com is replaced for the proper endpoint mapping.

With these examples, you can easily adapt the code to your preferred programming language, allowing for seamless integration with the Perfex CRM GraphQL API module.

Keep in mind that there are two types of allowed operations in Perfex's GraphQL API: queries and mutations. Comparing GraphQL to REST, queries operate like GET requests, while mutations operate like POST/PATCH/DELETE. The mutation name determines which modification is executed. You can find detailed examples of all available requests in the next two sections.

Sample Request-Responses


Retrieving Data



Adding Data



Updating Data



Deleting Data

Custom Modules Support

The Custom Modules Support feature in our module, offers unparalleled flexibility and capability, allowing users to interact with their data in a way that was previously challenging with traditional API approaches. Our module enables you to query every database table, field, and option seamlessly, including those created by third-party modules (non-native) developed by various authors and available within the Perfex CRM ecosystem.


This comprehensive support for custom modules means that you are not limited to the core functionalities of Perfex CRM; instead, you can extend your data interactions to encompass all elements of your CRM setup. Whether you are accessing standard client information, order details, or specific fields added by other developers, our module empowers you to retrieve and manipulate that data effortlessly.


The architecture of our GraphQL module is designed to maintain compatibility with existing modules and seamlessly integrate with custom implementations. This is especially beneficial for businesses that have invested in third-party solutions to enhance their CRM functionalities. By allowing direct queries on these custom entities, you gain a significant advantage in data accessibility, enabling more sophisticated reporting, analytics, and operational efficiency.


Furthermore, the capability to query custom modules means you can tailor your data interactions to fit your specific business needs. For instance, if a third-party module adds unique fields or custom workflows, you can retrieve that information through our GraphQL interface just as easily as you would with native Perfex data. This level of customization ensures that you can adapt the CRM to your evolving business requirements without losing the ability to access critical data points.


Third-Party Module's Data Handling Example

The following example uses Queries and Mutations for data stored by Google Workspace Integration module for Perfex CRM (non-native table):





In addition, our module supports complex data retrieval operations that allow you to explore relationships between various entities within your CRM. By leveraging the power of GraphQL, you can create nested queries that pull in related data across different modules. This means that when querying customer data, you can simultaneously fetch their associated orders, invoices, and even third-party custom fields in a single request, streamlining your data flow and enhancing your operational capabilities.


Overall, the Custom Modules Support feature is designed to provide maximum flexibility, efficiency, and control over your data interactions within Perfex CRM. With this powerful tool at your disposal, you can harness the full potential of Perfex CRM ecosystem, ensuring that all your data, regardless of its origin, is accessible and manageable through a unified GraphQL interface. This capability not only enhances your data strategy but also positions your business to respond rapidly to changes and opportunities in the market.

👩‍💻 Technical Support

We take great pride in offering reliable technical support to help ensure that our module operates as expected in its default factory state.

However, it's important to recognize that this module has been specifically crafted for users and developers who are proficient with GraphQL technology and possess a thorough understanding of how to configure, manage, and maintain custom connections with external services.

While we strive to provide a robust framework and the necessary tools for integrating GraphQL functionalities within Perfex CRM, it is crucial to understand that any form of customization, external configuration, or the establishment of connections with third-party services—such as webhooks or complex API integrations—falls outside the scope of our standard support offering.

Our support policy is guided by the CodeCanyon Item Support Policy, which ensures that we assist with resolving technical issues directly related to the module's core functionality in its unaltered form. Any issues that arise from modifying the module’s source code, implementing custom features, or configuring third-party services are not covered under the standard support policy.

It's also important to remember that our module is designed as a universal solution for integrating your CRM with various third-party services. However, due to the vast number of external platforms and APIs available, each with its own specific requirements and setup processes, we are unable to provide detailed configuration assistance or in-depth guides for every individual service.

For this reason, we recommend that users review the support documentation provided by the third-party services they wish to integrate with Perfex CRM. These resources often offer comprehensive instructions on how to configure API connections and are equipped to address integration-specific questions.

Synopsis of Scope

Our support is dedicated to ensuring that the module operates as it was designed, particularly with its installation and functionality within the Perfex CRM ecosystem. The primary purpose of the module is to enable efficient data exchange between your CRM and third-party sources.

We provide a robust framework that allows you to integrate your CRM with external services. However, the configuration, setup, and ongoing management of these third-party services, including tasks such as configuring webhooks or customizing API connections, are entirely the responsibility of the user.

Given the vast number of third-party services available, each with its own unique configuration processes and technical requirements, it would be unrealistic for us to offer tailored guides or customization support for each individual service.

Therefore, we recommend consulting the documentation and resources provided by the service you wish to integrate for specific guidance on configuring API connections and other requirements.

Support Cases

We provide technical support for the following scenarios:

  • Guidance with the installation of the module within Perfex CRM.
  • Ensuring the module functions as expected in its default state, as documented in the product description.
  • Offering online documentation that includes detailed commands, endpoints, parameters, and examples of requests and responses, enabling you to make the most out of the module.

If you experience any issues with the module's core functionality, feel free to raise a support ticket via our Support Area, and our team will assist you as promptly as possible.

Custom Requests

The following requests are not covered under our standard support policy, but our team can offer a quote for custom work on them:

  • Custom configurations or support with third-party API integrations beyond the module’s default setup.
  • Troubleshooting issues resulting from incorrect custom implementations or specific configurations related to external services.
  • Developing custom documentation or detailed guides for specific third-party services or GraphQL integrations.
  • Assistance with setting up webhooks or addressing specific service requirements that exceed the module’s intended use case.

We encourage users to explore the documentation and support resources offered by the third-party services they wish to integrate. Most services provide comprehensive guides on setting up API connections, and their dedicated support teams are often available to help with any integration-related questions. In many cases, submitting a support ticket with the service provider can prove to be highly effective in resolving specific issues.

Thank you for your understanding and cooperation.