Content restql in with parameters in restql http request is actually a request content. According to restql design
method divided from (get), to (post ), into (put), update (patch), delete (delete), the actual development, a lot of
teams for treatment from (get) might not follow rest standard treatment, we may need to deal with
to Format Description
- format
to users
with
id = "user.id"
username = "user.name"
password = "super.secret"
http post format
POST http://some.api/users/
BODY { "id": "user.id", "username": "user.name", "password": "super.secret"
Format wtih parameters
Support with simple and complex types of data formats (json, flat array process)
- Supported data types
- strings, double quotes
- number that can be floating-point types , is not supported by scientific notation
- Boolean, true, false
- list type, use brackets included
- Key / value data structure, similar json
- from the value of other query references, quotes and `.` references, similar json field references
Variable reference
We can easily pass parameters,
- The following format
from superheroes
with
name = $heroName
level = $heroLevel
powers = $heroPowers
Http request for the corresponding
localhost:9000/run-query?heroName="Superman"&heroLevel=99&heroPowers=["flight","heat vision","super strenght"]
Expand and flat processing
Expand the function and use of a flat, we would facilitate the processing of the transmission parameters
- Extended use of reference
from superheroes as party
with
id = [1, 2, 3]
http request format
GET http://some.api/superhero?id=1
GET http://some.api/superhero?id=2
GET http://some.api/superhero?id=3
- Reference flat processing
using->
mirrored conversion
from superheroes as fused
with
id = [1, 2, 3] -> flatten
http format
GET http://some.api/superhero?id=1&id=2&id=3
Value coding
Parameters can for encoding (such as base64, json)
- Reference Use
from superheroes as hero
with
stats = {health: 100,
magic: 100} -> json // encode this value as a json string
from superheroes as hero
with
bag = {capacity: 10} -> base64
Select the return value
We may choose to use only the data required by the application
- Reference format
from superheroes as hero
with
id = 1
only
name
items
skills.id
skills.name
nicknames -> matches("^Super")
Description:
in which we can use for further data filter match
Ignore errors
Sometimes for the wrong data queries we may not be interested in, we can ignore the error malicious use
- Reference format
from products as product
from ratings
with
productId = product.id
ignore-errors
Request header processing
Many times we api authentication process based on the request of the head, restql provides processing of the request header parameters
- Reference format
from superheroes as hero
headers
Authorization = "Basic user:pass"
Accept = "application/json"
with
id = 1
Timeout control
Many times slower response interfaces, we can set the timeout
- Reference format
from superheroes as hero
headers
Authorization = "Basic user:pass"
Accept = "application/json"
timeout 200
with
id = 1
cache control request header
We can add cache request header, convenient proxy cache processing request for a resource
use max-age = 600
from products
Request header
Reference material
http://docs.restql.b2w.io/#/restql/query-language?id=expanding-and-flattening