Skip to content

Instantly share code, notes, and snippets.

View e0ipso's full-sized avatar
🏠
Working from home

Mateu Aguiló Bosch e0ipso

🏠
Working from home
View GitHub Profile

Status

This extension was developed as part of the jsonapi module for Drupal.

Introduction

The JSON API specification is agnostic about how a server implements filtering strategies. In fact, the spec says:

Note: JSON API is agnostic about the strategies supported by a server. The filter query parameter can be used as the basis for any number of filtering strategies.

@e0ipso
e0ipso / read-only-property-es6.js
Last active March 16, 2024 21:09
Read only property ES6
/**
* Class that holds a read only property.
*/
class PropertyBag {
/**
* Accessor.
*
* @return {string}
* The value. This annotation can be used for type hinting purposes.

Status

This extension was developed as part of the jsonapi module for Drupal.

Introduction

It is possible for a server to have mixed success and error responses when dealing with a single or multiple entities at once. For instance, when generating collections of resource entities there is a chance that the GET operation results in a partial success. That is because each entity can generate errors independently from the other. In such scenarios the server MAY respond to the request with a partial success response.

Servers and clients MUST negotiate support for and use of the Partial Success extension as described in the base specification using partialsuccess as the name of the extension.

@e0ipso
e0ipso / constants.php
Created February 20, 2015 15:12
About constant overrides and Late Static Binding
<?php
class A {
const C = 'Class A';
public static function constantSelf() {
print self::C . PHP_EOL;
}
@e0ipso
e0ipso / contenta.gql
Last active October 12, 2018 12:59
Example schema with auto-resolvers from OpenAPI definitions
type Recipe {
id: String!
title: String!
author: User!
}
type User {
id: String!
name: String!
recipes: [Recipe]
}
@e0ipso
e0ipso / jsonapi-subrequest-write.md
Last active September 21, 2018 11:54
JSON API sub-request write operations

JSON API sub-request write operations

This extension allows you to alter or create the contents of the relationships of a resource with a single operation. In order to control how the relationships, and their relationships in turn, are affected by the request this extension reserves the keyword subrequest inside of the meta of any relationship. The contents of the subrequest property MUST be a request object.

The request object MUST NOT be present if the relationship item is not being altered or created via POST, PUT or PATCH.

@e0ipso
e0ipso / api-first-priorities.md
Last active October 13, 2017 15:14
API-First Priorities
@e0ipso
e0ipso / uuid-setter.php
Created March 11, 2017 10:44
Allow setting the UUID from the front-end
<?php
/**
* Implements hook_entity_property_info_alter().
*/
function mymodule_entity_property_info_alter(&$info) {
// Add the uuid setter if not present.
foreach (entity_get_info() as $entity_type => $entity_info) {
if (
!empty($entity_info['uuid'])
@e0ipso
e0ipso / JSONAPI Authenticated
Created September 16, 2016 13:02
JSONAPI and RESTful Web Services performance comparison
====================================================================================================
AUTHENTICATED
====================================================================================================
>$ ab -v1 -k -c8 -n10 -A admin:admin http://d8dev.local/api/node/article/900b681b-581a-4624-9ff6-99cc865df429\?_format\=api_json\&include\=uid,uid.user_picture,field_tags
This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking d8dev.local (be patient).....done