GraphQL Jay adapter for JSON Hyper-Schema (draft-04)
$ npm install --save graphql-jay-hyperschema
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
}
}
each
Use to resolve relations with an unique href
for each item from a target field.
{
"rel": "urls",
"href": "{+item}",
"each": "urls"
}
linkRel
Use to relate to another LDO
based on schema
values.
{
"rel": "tatooine",
"linkRel": {
"id": "planetWithId",
"values": {
"id": "1"
}
}
}
MIT © Mateus Maso