Skip to content

ResponseQL is a lightweight GraphQL without conditions, functions and fragments

Notifications You must be signed in to change notification settings

devlab-group/response-ql

Repository files navigation

Response QL

Is extra lightweight implementation of Query Language for web applications. It supports direct fields only without any extra behavior.

Let's select all friends props for user:

{
  user {
    name, friends{*}
  }
}

Each entity has required fields which will be returned in any way, such an ID, so there is no reason to specify them. If passed asterisk {*} then all properties will be extracted.

Install

Via npm:

npm i response-ql

Usage

const parse = require('response-ql');

parse('user{location}'); // -> Map {"user" => Map {"location" => null}}
parse.parse('user{location}'); // -> [{name: 'user', props:[{name: 'location', props: null}]}]

Example output:

[{
  name: 'user',
  props: [{
    name: 'location',
    props: null
  }]
}]

Single line

When properties follow in one line it should be separated with comma.

user{name, email, birthday, city, cars{*}}

Multiline

When properties separated with new line, comma could be omitted:

user {
  name, email
  birthday
  city
  cars{*}
}

License

MIT.

About

ResponseQL is a lightweight GraphQL without conditions, functions and fragments

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published