restql
v1.2.3
Published
RESTful API Resolver for Nested-Linked Resources | 🕸 🕷
Maintainers
Readme
RestQL
RESTful API Resolver for Nested-Linked Resources | 🕸 🕷
RestQL allows you to dynamically resolve nested-linked resources of a RESTful API.
By specifying a set of properties to describe the paths.
Installation
npm
npm install restqlCDN
<script src="https://unpkg.com/restql/dist/index.min.js"></script>Usage
restql<T>(resource, resolver[, options])
Parameters
resource(string): The main resource to fetch.
Example
'https://pokeapi.co/api/v2/pokemon/1'resolver(Resolver): The resolver to apply.- At every level, each property describes a path to the nested resources within the same.
- RestQL fetches all resources and calls the next resolver against them.
- Until it reaches the base case (
null), from which it returns a merged response.
Quantifiers
Following is a table of quantifiers you can use:
| Quantifier | Description |
| ---------- | ------------------------- |
| [] | Collection of properties. |
| ? | Optional property. |
Example
{
'abilities[]?.ability.url': {
'generation.url': {
'main_region.url': null,
},
},
'stats[].stat.url?': {
'affecting_natures.increase[].url': null,
'affecting_natures.decrease[].url': null,
},
'moves[].move?.url': null,
}[options](RequestInit): The options to configure.
Example
{ ... }Returns
(Promise<T>): A promise which resolves into a generic.
Try It
npm run playgroundRoadmap
- ~~Support for authentication~~
- ~~Support for optional resolvers~~
- ~~Improve package bundler~~
- ~~Ability to cache responses~~
- Support for recursive resolvers
Take 🎂, Folks! 🌮 🐴 💨
