Custom APIs for Complex Queries


You can create Custom REST or GraphQL API endpoints for your user-defined complex queries for specific read/write operations on the database.

Neurelo auto-generates a rich set of APIs from your schema for the project. However, there are times when you need to extend this capability for complex operations you may want to run from your application. A complex query normally involves more intricate and sophisticated operations than can be supported using Neurelo's Auto-Generated APIs.

  • Custom APIs for Complex Queries is a powerful feature that allows users to leverage native query code (SQL or MQL), save them as API endpoints, and run operations in the database using these endpoints from your application.

  • Custom APIs can be created for MySQL, PostgreSQL, or MongoDB databases, and can be integrated into a wide range of applications and websites.

  • Custom APIs are supported both as REST endpoints or GraphQL endpoints

Complex queries usually involve multiple criteria, conditions, or operations to extract specific and nuanced information from the database.

For example in relational databases, complex queries often include features such as:

  1. Multiple Tables: Involving complex joins across multiple database tables to retrieve data from related sources.

  2. Aggregation: Using aggregate functions (like sum, avg, count) to perform calculations on groups of data.

  3. Subqueries: Nesting one query inside another to retrieve data in a step-by-step manner.

  4. Conditional Logic: Applying complex conditions using logical operators (AND, OR) for filtering data based on specific criteria.

While many of these complex queries can be performed using Neurelo's Auto-Generated API endpoints, sometimes users need to extend the capability to beyond what can be done with the auto-generated APIs.

Neurelo offers users the ability to write and test custom queries against their data sources in a project and to create API endpoints from these custom queries. This capability allows users to extend Neurelo's APIs and to have complete flexibility to query and update the data from their data sources.

Here’s how to access and use this section:

  1. Accessing Custom Queries:

    • Navigate to the "Definitions" section on your Neurelo Dashboard inside a project. Within Definitions, you will fine the tabs "Schema," "Custom Queries," and "Docs."

    • Click on the "Custom Queries" tab to enter this section.

  2. Capabilities in Custom Queries Section:

    • Write Custom Queries: Utilize the query editor to write and refine custom database queries.

    • Search Feature: Browse through all your available custom queries using the search functionality.

    • Create API Endpoints: Generate API endpoints with methods like "GET" "POST", "PATCH", and "DELETE" for REST and turning your queries into accessible endpoints for developers. You can also build Custom APIs for GraphQL for Queries or Mutations.

    • Custom API Endpoint Naming: Assign names to your Custom Query API endpoints. Once deployed, you can call these endpoints using the assigned name at

      • /custom/<endpointName> for REST using the configured HTTP method

      • custom_endpointName for GraphQL as the field name in a Query or Mutation

    • AI-Assisted Query Generation: Leverage AI assistance to generate custom queries using conversational text, simplifying the query creation process.

    • Test Queries: Test your queries written in the editor to ensure accuracy and expected outcomes.

    • Set Execution Timeouts: Define upper limits on the execution time for your queries, ranging from 0 to 60,000 milliseconds, to have predictable performance. If the query runs longer for the configured execution time, it will be terminated.

    • Commit on Branches: Commit your queries into your working branch.

The Custom Queries workspace in Neurelo is a powerful capability, empowering you to manage extend Neurelo capabilities for your application by utilizing AI for enhanced query code generation, all contributing to a more efficient and powerful application development process.

Last updated