Skip to content

Instantly share code, notes, and snippets.

View zdne's full-sized avatar
💭
🚀

Z zdne

💭
🚀
View GitHub Profile
@zdne
zdne / hal-embedding.md
Last active June 5, 2019 12:47
Explanation of HAL+JSON embedding

Embedding Related Resoruces in HAL

Often, I get questions about embedding resources with HAL http://stateless.co/hal_specification.html. Here is some of my recommendation illustrated on an example.

First of all, think of the _embedded as a courtesy of HAL so the API user does not have to make one more call to retrieve a resource that has a link relation with the current (self resource). Let's illustrate it on an example: A collection of applications and one application, where an application might have related, child applications. The link relations are as follow:

collection of applications resource ——application relation——> application resource

application resource ——child relation——> application resource

Keybase proof

I hereby claim:

  • I am zdne on github.
  • I am zdenek (https://keybase.io/zdenek) on keybase.
  • I have a public key ASBe1huF1XGh7mDwe5wbzdbPAShqtgw56p1S0n22kXYAyQo

To claim this, I am signing this object:

@zdne
zdne / stuff.md
Last active January 14, 2017 20:22
  1. Retrieve WeatherReport where address is Anchorage, Alaska
  2. Send Payment where the recipient is https://keybase.io/phil and currency is USD and amount is 40
  3. Send Message where the recipient is https://keybase.io/phil and text is Hey Phil ...
@zdne
zdne / schemaUtils.js
Created January 14, 2017 06:59 — forked from jarwol/schemaUtils.js
GraphQL diff() and merge() extensions
'use strict';
/**
* This module extends the graphql.js schema and types by adding diff and merge functions.
*/
(function () {
const GraphQLSchema = require('graphql/type/schema').GraphQLSchema,
GraphQLObjectType = require('graphql/type/definition').GraphQLObjectType,
GraphQLScalarType = require('graphql/type/definition').GraphQLScalarType,
GraphQLUnionType = require('graphql/type/definition').GraphQLUnionType,
# Using a terms from schema.org dictionary,
# find services that offers WeatherForecast.
services = apiRegistry.find(WeatherForecast, { vocabulary: "http://schema.org"})
# Query a service for WeatherForecast at GeoCoordinates.
forecast = service.retrieve(WeatherForecast, { GeoCoordinates: … })
# Display Temperature
print forecast(Temperature)

Keybase proof

I hereby claim:

  • I am zdne on github.
  • I am zdenek (https://keybase.io/zdenek) on keybase.
  • I have a public key whose fingerprint is AAB0 458B 4299 95C4 5C9F 0CE0 1205 3F7F C8E6 F7A4

To claim this, I am signing this object:

# Fizz Buzz Solving API Blueprint
## Data Structures
## Main (array)
This only does 1 through 15.
### Members
- !map
- (array)
# User [/users/{id}]
- Attributes (object)
- name: John
- email: john@apiary.io
## Retrieve [GET]
- Response 200 (application/json)
- Attributes (User)
## Remove [DELETE]
# API
## Globals Parameters
- version: 1.0 (string) - Version of the API
# Resource A [/{version}/some/path/to/a]
# Resource B [/{version}/some/path/to/b]