Dynamic API query method and system based on MQL language packaging

By adopting a dynamic API query method based on MQL language in software development, the balance between standardization and flexibility of RESTful API and GraphQL is solved, and efficient and flexible data query and processing is achieved, improving system performance and users Experience.

CN119474127APending Publication Date: 2025-02-18FUJIAN FUJITSU COMM SOFTWARE CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411520071.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-29
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

The prior art is difficult to find a balance between the standardization of RESTful API and the flexibility of GraphQL in software development, resulting in data redundancy, fixed data structures and multi-request problems, affecting system performance and user experience.

Method used

Using a dynamic API query method based on MQL language, we use the MQL syntax and generate lexical parser to build a MiddleExpression intermediate model and convert it into an ORM query object, automate the processing of query requests, and optimize the data interaction process.

Benefits of technology

It realizes the flexibility and efficiency of data query, reduces unnecessary data transmission, improves the accuracy of data processing and system performance, reduces the complexity of development and maintenance, and improves user experience and system scalability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119474127A_ABST
    Figure CN119474127A_ABST
Patent Text Reader

Abstract

The invention discloses a dynamic API query method and system based on MQL language packaging. The method comprises the steps that a dynamic API query request is generated on the basis of self-defined MQL grammar of a request side and analyzed to obtain the MQL grammar; converting the MQL grammar into an intermediate expression model object program logic; the MiddleExpress intermediate model is converted into a program logic of a query object corresponding to the ORM; a controller API object of the query object of the ORM is converted into program logic of an MQL interface document conforming to the OpenApi specification; the program logic of the MQL interface document realizes a program interface of MQL query; the request side constructs a corresponding request object according to the MQL document, converts the corresponding request object into an ORM object and then adds custom processing logic; and converting the ORM object into an MQLResult object conforming to a request expected result, serializing the MQLResult object into a data range field conforming to the request requirement, and returning the data range field. According to the method, data query is simpler, more efficient and lower in consumption.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer software development, and in particular to a dynamic API query method and system based on MQL language encapsulation. Background Art

[0002] In today's software development field, data management and API design are core components, especially finding a balance between changing client requirements and server resource optimization. The main technical solutions include: RESTful API: One of the most widely used API design methods, it relies on a stateless, client-server, cacheable communication protocol. The main advantages of RESTful API are simplicity, ease of understanding and implementation, and it is usually based on the HTTP standard, ensuring good interoperability. Disadvantages of RESTful API: Data redundancy: The client may need to obtain data from multiple endpoints, which may cause the same data to be sent repeatedly between multiple requests. Fixed data structure: RESTful APIs usually return predefined and fixed data structures, which limits the flexibility of the front end in processing and displaying data. Multiple request problem: For complex interfaces, multiple API calls are required to collect enough data, increasing network latency and loading time.

[0003] GraphQL: As a data query language, GraphQL allows clients to precisely specify the data they need, effectively avoiding the problems of over-fetching and under-fetching data. It uses a type system to describe data, allowing clients to construct complex queries and accurately obtain the required information. Disadvantages of GraphQL: Performance issues: If not managed correctly, complex queries may cause server performance problems. Cache complexity: Since each query may be unique, standard HTTP caching strategies are difficult to apply directly to GraphQL. Excessive flexibility: Although flexibility provides convenience for the front end, it may also lead to API abuse, such as requesting too much data. Overly complex implementation: It is difficult to integrate into the existing technical system, and requires a lot of disruptive changes to the original system architecture and API design. Summary of the invention

[0004] The purpose of the present invention is to provide a dynamic API query method and system based on MQL language encapsulation, which combines the standardization of RESTful API with the flexible query characteristics of GraphQL to make data query simpler, more efficient and less expensive. The method allows the front end to accurately define query requirements, the back end to automatically process, and optimize the entire data interaction process.

[0005] The technical solution adopted by the present invention is: A dynamic API query method based on MQL language encapsulation, comprising the following steps: Step 1, define the MQL grammar and generate a lexical parser for MQL grammar parsing of dynamic API query requests; Furthermore, ANTRL is used for lexical parser, and the corresponding MQL grammar parsing program logic is written to generate a lexical parser.

[0006] Step 2, build the MiddleExpression intermediate model, convert the MQL syntax into the intermediate expression model object program logic; Step 3: Convert the MiddleExpression intermediate model into the program logic of the corresponding ORM query object according to the selected ORM model; Step 4: Convert the controller API object of the ORM query object into the program logic of the MQL interface document that complies with the OpenApi specification; Furthermore, the program logic of the MQL interface document of the OpenApi specification is automatically generated by using the interface definition method.

[0007] Step 5: Define the program interface of the MQL query to be implemented in combination with the program logic of the MQL interface document; Furthermore, the program interface for implementing the MQL query includes determining the request field, the sort field range, the query field, and the query operator of the corresponding field.

[0008] Step 6: The request side constructs the corresponding request object according to the MQL document. The service side converts the MiddleExpression intermediate expression through MQL lexical analysis, converts the MiddleExpression into an ORM object, and directly adds custom processing logic through the ORM object; Furthermore, adding custom processing logic in step 6 includes adding custom data permission filtering.

[0009] Step 7: Convert the ORM object into an MQLResult object that meets the expected result of the request, and serialize it into a data range field that meets the requirements of the request to return the query result.

[0010] A self-developed MQL language encapsulation dynamic API query system, which includes: API service: Provides SDK embedded in the application service process to implement request reception and analysis and intermediate link processing, and finally returns the dynamic API query results to the caller of the request; MQL lexical analysis engine: defines MQL grammar and verifies the MQL grammar in the request and converts it into MiddleExpression intermediate model object; ORM translator: translates the MiddleExpression intermediate model object into the corresponding ORM extended query object according to the configuration, so as to implement custom logic by processing the ORM extended query object; MQLResult parser: It processes the execution result of the ORM extended query object and converts it into a structure type that conforms to the MQL expression definition, and then returns the result to the requester after serialization; MQL Object Controller: defines the path, query scope, sorting scope, filter conditions, operators allowed by the filter conditions, and the type of returned result objects of the MQL request, and limits the capabilities of the interface; MQL API Generator: Automatically translate the API objects of the MQL object controller into interface documents that comply with the OpenApi specification.

[0011] Furthermore, the MQL lexical analysis engine ANTRL performs a lexical parser.

[0012] The present invention adopts the above technical solution, which has the following technical advantages compared with the prior art: 1. Demand-based data acquisition: By allowing the front end to accurately define the required data, unnecessary data transmission is avoided, thereby improving the accuracy of data processing and reducing system resource consumption. 2. Automated query construction: Customize the MQL language to dynamically build dynamic ORM objects according to front-end requests, reduce development and maintenance workload, and improve the adaptability and efficiency of the API. 3. Improve development efficiency: Simplify data query implementation, reduce front-end and back-end communication and debugging time, and accelerate the development process. 4. Enhance user experience: Provide users with faster application response speed and more accurate data loading, and improve the interactive experience. 5. Improve scalability and maintainability: Design an API that is easy to expand and maintain to adapt to future business growth and changes while maintaining the stability and reliability of the system. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] The present invention is further described in detail below with reference to the accompanying drawings and specific embodiments; Figure 1 The present invention is a flowchart of a dynamic API query method based on MQL language encapsulation. Implementation

[0014] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.

[0015] like Figure 1 As shown, the present invention discloses a dynamic API query method based on MQL language encapsulation, which includes the following steps: Step 1, define the MQL grammar and generate a lexical parser for MQL grammar parsing of dynamic API query requests; Furthermore, ANTRL is used for lexical parser, and the corresponding MQL grammar parsing program logic is written to generate a lexical parser.

[0016] Step 2, build the MiddleExpression intermediate model, convert the MQL syntax into the intermediate expression model object program logic; Step 3: Convert the MiddleExpression intermediate model into the program logic of the corresponding ORM query object according to the selected ORM model; Step 4: Convert the controller API object of the ORM query object into the program logic of the MQL interface document that complies with the OpenApi specification; Furthermore, the program logic of the MQL interface document of the OpenApi specification is automatically generated by using the interface definition method.

[0017] Step 5: Define the program interface of the MQL query to be implemented in combination with the program logic of the MQL interface document; Furthermore, the program interface for implementing the MQL query includes determining the request field, the sort field range, the query field, and the query operator of the corresponding field.

[0018] Step 6: The request side constructs the corresponding request object according to the MQL document. The service side converts the MiddleExpression intermediate expression through MQL lexical analysis, converts the MiddleExpression into an ORM object, and directly adds custom processing logic through the ORM object; Furthermore, adding custom processing logic in step 6 includes adding custom data permission filtering.

[0019] Step 7: Convert the ORM object into an MQLResult object that meets the expected result of the request, and serialize it into a data range field that meets the requirements of the request to return the query result.

[0020] A self-developed MQL language encapsulation dynamic API query system, which includes: API service: Provides SDK embedded in the application service process to implement request reception and analysis and intermediate link processing, and finally returns the dynamic API query results to the caller of the request; MQL lexical analysis engine: defines MQL grammar and verifies the MQL grammar in the request and converts it into MiddleExpression intermediate model object; ORM translator: translates the MiddleExpression intermediate model object into the corresponding ORM extended query object according to the configuration, so as to implement custom logic by processing the ORM extended query object; MQLResult parser: It processes the execution result of the ORM extended query object and converts it into a structure type that conforms to the MQL expression definition, and then returns the result to the requester after serialization; MQL Object Controller: defines the path, query scope, sorting scope, filter conditions, operators allowed by the filter conditions, and the type of returned result objects of the MQL request, and limits the capabilities of the interface; MQL API Generator: Automatically translate the API objects of the MQL object controller into interface documents that comply with the OpenApi specification.

[0021] Furthermore, the MQL lexical analysis engine ANTRL performs a lexical parser.

[0022] Possible application cases of the present invention include: 1. Low-code platform development: In the development of a low-code application platform, the MQL dynamic API query method of this patent can greatly simplify the process of data interaction and building back-end services. The low-code platform uses MQL technology at the bottom layer, and non-technical users can define data query requirements in a graphical manner, thereby reducing dependence on traditional programming and accelerating application development and deployment. 2. Business system API query development: This patented method can be widely used in various business systems, especially in situations where API queries need to be developed and modified quickly. It allows developers to directly build and modify data queries through the declarative MQL language, improve development flexibility and response speed, and is particularly suitable for multi-terminal access adaptation and business environments with frequently changing requirements.

[0023] The present invention adopts the above technical solution, which is different from the existing RESTful API and GraphQL API. It combines the standardization of RESTful API and the flexibility of GraphQL, and optimizes the data query and processing process in an innovative way. By defining a flexible, declarative query language MQL, the present invention allows developers to accurately specify the required data fields and filter conditions through simple descriptions, thereby dynamically building back-end ORM queries. This method not only significantly improves the efficiency and accuracy of data processing, but also reduces the complexity of development and maintenance. In addition, by automating the processing of these queries on the server side, the present invention further reduces the burden on the front end, making the overall design of the API both efficient and easy to expand, which is particularly suitable for data interaction scenarios that require high customization and frequent changes.

[0024] Compared with the prior art, the present invention has the following technical advantages: 1. Demand-based data acquisition: By allowing the front end to accurately define the required data, unnecessary data transmission is avoided, thereby improving the accuracy of data processing and reducing system resource consumption. 2. Automated query construction: Customize the MQL language to dynamically build dynamic ORM objects based on front-end requests, reduce development and maintenance workload, and improve the adaptability and efficiency of the API. 3. Improve development efficiency: Simplify data query implementation, reduce front-end and back-end communication and debugging time, and accelerate the development process. 4. Enhance user experience: Provide users with faster application response speed and more accurate data loading, and improve the interactive experience. 5. Improve scalability and maintainability: Design an API that is easy to expand and maintain to adapt to future business growth and changes while maintaining the stability and reliability of the system.

[0025] Obviously, the described embodiments are part of the embodiments of the present application, rather than all of the embodiments. In the absence of conflict, the embodiments in the present application and the features in the embodiments can be combined with each other. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the detailed description of the embodiments of the present application is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians of the art without making creative work are within the scope of protection of the present application.

Claims

1. A dynamic API query method based on MQL language encapsulation, characterized by: It includes the following steps: Step 1, define the MQL grammar and generate a lexical parser for MQL grammar parsing of dynamic API query requests; Step 2: Build the MiddleExpression intermediate model to convert the MQL syntax into the intermediate expression model object program logic; Step 3: Convert the MiddleExpression intermediate model into the program logic of the corresponding ORM query object according to the selected ORM model; Step 4: Convert the controller API object of the ORM query object into the program logic of the MQL interface document that complies with the OpenApi specification; Step 5: Define the program interface of the MQL query to be implemented in combination with the program logic of the MQL interface document; Step 6: The request side constructs the corresponding request object according to the MQL document. The service side converts the MiddleExpression intermediate expression through MQL lexical analysis, converts the MiddleExpression into an ORM object, and directly passes it through the ORM object. Add custom processing logic; Step 7: Convert the ORM object into an MQLResult object that meets the expected result of the request, and serialize it into a data range field that meets the requirements of the request to return the query result.

2. According to a dynamic API query method based on MQL language encapsulation according to claim 1, it is characterized in that: In step 1, ANTRL is used for lexical parser, and the corresponding MQL grammar parsing program logic is written to generate a lexical parser.

3. According to a dynamic API query method based on MQL language encapsulation according to claim 1, it is characterized in that: In step 4, the program logic of the MQL interface document of the OpenApi specification is automatically generated by using the interface definition method.

4. According to a dynamic API query method based on MQL language encapsulation according to claim 1, it is characterized in that: The contents of the program interface for implementing MQL query in step 5 include determining the request field, sort field range, query field, and query operators for the corresponding fields.

5. According to a dynamic API query method based on MQL language encapsulation according to claim 1, it is characterized in that: Adding custom processing logic in step 6 includes adding custom data permission filtering.

6. A self-developed MQL language encapsulation dynamic API query system, which adopts a dynamic API query method based on MQL language encapsulation according to any one of claims 1 to 5, characterized in that: The system includes: API service: Provides SDK embedded in the application service process to implement the reception and analysis of dynamic API query requests and intermediate link processing, and finally returns the query results of dynamic API queries to the caller of the request; MQL lexical analysis engine: defines MQL grammar, verifies MQL grammar in the request and converts it into MiddleExpression intermediate model object; ORM translator: translates the MiddleExpression intermediate model object into the corresponding ORM extended query object according to the configuration, so as to implement custom logic by processing the ORM extended query object; MQLResult parser: It processes the execution result of the ORM extended query object and converts it into a structure type that conforms to the MQL expression definition, and then returns the result to the requester after serialization; MQL Object Controller: defines the path, query scope, sorting scope, filter conditions, operators allowed by the filter conditions, and the type of returned result objects of the MQL request, and limits the capabilities of the interface; MQL API Generator: Automatically translate the API objects of the MQL object controller into interface documents that comply with the OpenApi specification.

7. A dynamic API query system based on MQL language encapsulation according to claim 6, characterized in that: The MQL lexical analysis engine ANTRL is used as the lexical analyzer.

Citation Information

Cited By

  • Java language LINQ expression implementation method based on chained call

    CN120723210A

  • Analysis system and analysis method based on Redis and MQL

    CN121636543A