restql-core

Microservice query language

License

License

MIT
Categories

Categories

Java Languages
GroupId

GroupId

com.b2wdigital
ArtifactId

ArtifactId

restql-core-java
Last Version

Last Version

3.5.5
Release Date

Release Date

Type

Type

jar
Description

Description

restql-core
Microservice query language
Project URL

Project URL

https://github.com/B2W-BIT/restQL-core-java
Source Code Management

Source Code Management

https://github.com/B2W-BIT/restQL-core-java

Download restql-core-java

How to add to project

<!-- https://jarcasting.com/artifacts/com.b2wdigital/restql-core-java/ -->
<dependency>
    <groupId>com.b2wdigital</groupId>
    <artifactId>restql-core-java</artifactId>
    <version>3.5.5</version>
</dependency>
// https://jarcasting.com/artifacts/com.b2wdigital/restql-core-java/
implementation 'com.b2wdigital:restql-core-java:3.5.5'
// https://jarcasting.com/artifacts/com.b2wdigital/restql-core-java/
implementation ("com.b2wdigital:restql-core-java:3.5.5")
'com.b2wdigital:restql-core-java:jar:3.5.5'
<dependency org="com.b2wdigital" name="restql-core-java" rev="3.5.5">
  <artifact name="restql-core-java" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.b2wdigital', module='restql-core-java', version='3.5.5')
)
libraryDependencies += "com.b2wdigital" % "restql-core-java" % "3.5.5"
[com.b2wdigital/restql-core-java "3.5.5"]

Dependencies

compile (2)

Group / Artifact Type Version
b2wdigital » restql-core jar 3.5.5
com.fasterxml.jackson.core : jackson-databind jar 2.9.10.1

test (1)

Group / Artifact Type Version
junit : junit jar 4.11

Project Modules

There are no modules declared in this project.

Build Status

restQL-core-java

restQL-core allows you to run restQL queries directly from JVM applications, making easy to fetch information from multiple services in the most efficient manner. e.g.:

from search
    with
        role = "hero"

from hero as heroList
    with
        name = search.results.name

You can learn more about restQL query language here and here

restQL-core is built upon the battle proven HttpKit and Clojure core.async to maximize performance and throughtput.

If you're using Clojure you may want to check restQL-core or restQL-Server if you're using another languagem or working in a client application.

Getting Started

Installation

Add Clojars repository and restQL dependency to your project

Maven

<repositories>
    <repository>
        <id>clojars.org</id>
        <url>http://clojars.org/repo</url>
    </repository>
</repositories>
...
<dependency>
	<groupId>com.b2wdigital</groupId>
        <artifactId>restql-core-java</artifactId>
       	<version>3.5.5</version>
</dependency>

Gradle

repositories {
    maven { 
        url "http://clojars.org/repo"
  }
}
...
compile 'com.b2wdigital:restql-core-java:3.5.5'

First query

ClassConfigRepository config = new ClassConfigRepository();
config.put("planets", "https://swapi.co/api/planets/:id");

RestQL restQL = new RestQL(config);
QueryResponse response = restQL.executeQuery("from planets with id = ?", 1);

System.out.println("The response JSON is: " + response.toString());

In the example above restQL will call StarWars planet API passing "1" as param.

Configuration

restQL receives a configuration class with the API mappings. You can use the available configuration repositories -- SystemPropertiesConfigRepository, PropertiesFileConfigRepository or ClassConfigRepository -- or implement your own, using the ConfigRepository interface.

You can check more about endpoints configuration here

Examples

Simple Query

Retrieving all magic cards

ClassConfigRepository config = new ClassConfigRepository();
config.put("cards", "http://api.magicthegathering.io/v1/cards");

RestQL restQL = new RestQL(config);

String query = "from cards as cardslist params type = ?";

QueryResponse response = restQL.executeQuery(query, "Artifact");

// The JSON String
String jsonString = response.toString();

// The mapped object
List<MTGCard> cards = result.getList("cardslist", MTGCard.class);

Chained Query

Listing all cards and then fetching its details.

ClassConfigRepository config = new ClassConfigRepository();
config.put("cards", "http://api.magicthegathering.io/v1/cards");
config.put("card", "http://api.magicthegathering.io/v1/cards/:id");

RestQL restQL = new RestQL(config);

String queryCardsAndDetails = "from cards as cardsList params type = ? \n"
                            + "from card as cardWithDetails params id = cardsList.id";

QueryResponse response = restQL.executeQuery(queryCardsAndDetails, "Artifact");

// The JSON String
String jsonString = response.toString();

// The mapped object
List<MTGCard> cards = result.getList("cardWithDetails", MTGCard.class);

Building From Source Code

As prerequisites to build restQL from source we have:

  • Java 11
  • Maven 3

Just clone this repo and run "mvn compile".

License

Copyright © 2016 B2W Digital

Distributed under the MIT License.

com.b2wdigital

B2W Digital

B2W Digital

Versions

Version
3.5.5
2.8.17
2.2.2
2.2.1
2.2