currently the project is in its infant stage and requires both testing & collaboration although early results are promising
To create a simple way to query only the required data from rest api without relying on lot of external tools or code.
This project is inspired from GraphQl
But unlike graphql which is itself a whole new query language, restgraph aims to create a much simpler approach where you just write a simple special string which is used to parse and minify data
Suppose we have something like this
{
"rest" : {
"query: {
"lang" : "",
"map" : "",
"name" : "",
"age" : 2
}
}
}
Now if I just want 2 keys inside query, I can write a special map {rest{query{lang,map}}}
which will return only the required data just like graphql
{
"rest" : {
"query: {
"lang" : "",
"map" : ""
}
}
}
The map is generated by providing the required json object in the createMap()
function. Basically the map is a simple json removing all double quotes and end values + replacing array with object notation i.e. you can treat it something really similar to graphql queries without extra spaces or anthing
You can verify a map by using verifyMap()
function
Now to parse the data according to our requirement we can pass out map & original data directly to mapData(map,data)
function which will return the expected output
The goal is to make it as simple as possible for both frontend (mainly) and backend devs
- One of the way is to ask the client to send the map via header
restgraph
param (again completely upto you which way you want the map) - Create a middleware function in your express, koa, hapi etc and wait for the normal response after which you can simply check for
restgraph
, verify the graph (if u want) & then send themapData
output - You can also use it inside a single route, again completely upto you
Right now the library is in its early stages and I want to test it thouroughly before recommending and putting it on npm. Also I planning to make simple libraries for other lang as well.
Really need someone to test and collaborate in the same
- Twitter - @dawnimpulse
- Email - dawnimpulse@gmail.com
ISC License
Copyright 2020, Saksham (DawnImpulse)
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted,
provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
OR PERFORMANCE OF THIS SOFTWARE.
Written with StackEdit.