Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mateusmaso/graphql-jay-hyperschema
GraphQL Jay adapter for JSON Hyper-Schema (draft-04)
https://github.com/mateusmaso/graphql-jay-hyperschema
graphql-jay javascript json-hyper-schema
Last synced: 10 days ago
JSON representation
GraphQL Jay adapter for JSON Hyper-Schema (draft-04)
- Host: GitHub
- URL: https://github.com/mateusmaso/graphql-jay-hyperschema
- Owner: mateusmaso
- Created: 2016-09-09T01:42:09.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-01-05T23:07:23.000Z (almost 8 years ago)
- Last Synced: 2024-10-12T19:34:01.852Z (24 days ago)
- Topics: graphql-jay, javascript, json-hyper-schema
- Language: JavaScript
- Homepage:
- Size: 21.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# graphql-jay-hyperschema [![Build Status](https://travis-ci.org/mateusmaso/graphql-jay-hyperschema.svg?branch=master)](https://travis-ci.org/mateusmaso/graphql-jay-hyperschema)
GraphQL Jay adapter for JSON Hyper-Schema (draft-04)
## Install
```
$ npm install --save graphql-jay-hyperschema
```## Usage
```javascript
import {adapter} from "graphql-jay-hyperschema"var url = "http://myservice.com/api/v1"
export default function service() {
var metadata = {
"$schema": "http://json-schema.org/draft-04/hyper-schema#",
"type": "object",
"definitions": {
"user": {
"type": "object",
"properties": {...},
"required": [...],
"links": [...]
}
},
"properties": {
"user": {
"$ref": "#/definitions/user"
}
},
"links": [{
"rel": "user",
"href": "/users/{id}",
"schema": {
"type": "object",
"properties": {
"id": {
"type": "number"
}
},
"required": ["id"]
},
"targetSchema": {
"$ref": "#/definitions/user"
}
}]
}return {
url,
metadata,
adapter
}
}
```## ```LDO``` extra properties
**each**
Use to resolve relations with an unique ```href``` for each item from a target field.
```json
{
"rel": "urls",
"href": "{+item}",
"each": "urls"
}
```**linkRel**
Use to relate to another ```LDO``` based on ```schema``` values.
```json
{
"rel": "tatooine",
"linkRel": {
"id": "planetWithId",
"values": {
"id": "1"
}
}
}
```## License
MIT © [Mateus Maso](http://www.mateusmaso.com)