https://github.com/relztic/restql
RESTful API Resolver for Nested-Linked Resources | 🕸 🕷
https://github.com/relztic/restql
api package recursive resolver rest typescript
Last synced: 21 days ago
JSON representation
RESTful API Resolver for Nested-Linked Resources | 🕸 🕷
- Host: GitHub
- URL: https://github.com/relztic/restql
- Owner: relztic
- License: mit
- Created: 2017-10-15T01:00:53.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2026-03-07T21:15:27.000Z (22 days ago)
- Last Synced: 2026-03-08T02:40:49.151Z (22 days ago)
- Topics: api, package, recursive, resolver, rest, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/restql/
- Size: 168 KB
- Stars: 17
- Watchers: 0
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RestQL
RESTful API Resolver for Nested-Linked Resources | 🕸 🕷
---
[](https://www.npmjs.com/package/restql)


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
```sh
npm install restql
```
### CDN
```html
```
## Usage
### `restql(resource, resolver[, options])`
#### Parameters
- `resource` (`string`): The main resource to fetch.
##### Example
```js
'https://pokeapi.co/api/v2/pokemon/1'
```
- `resolver` ([`Resolver`](https://github.com/relztic/restql/blob/main/src/types.ts#L1)): 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
```js
{
'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`](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)): The options to configure.
##### Example
```js
{ ... }
```
#### Returns
(`Promise`): A promise which resolves into a generic.
## Try It
```sh
npm run playground
```
[See Playground](https://github.com/relztic/restql/blob/main/playground/index.ts)
## Roadmap
- ~~Support for authentication~~
- ~~Support for optional resolvers~~
- ~~Improve package bundler~~
- ~~Ability to cache responses~~
- Support for recursive resolvers
> Take 🎂, Folks! 🌮 🐴 💨