Skip to content

Instantly share code, notes, and snippets.

@ClemensSahs
ClemensSahs / Event-stream based GraphQL subscriptions.md
Created February 26, 2017 15:24 — forked from OlegIlyenko/Event-stream based GraphQL subscriptions.md
Event-stream based GraphQL subscriptions for real-time updates

In this gist I would like to describe an idea for GraphQL subscriptions. It was inspired by conversations about subscriptions in the GraphQL slack channel and different GH issues, like #89 and #411.

Conceptual Model

At the moment GraphQL allows 2 types of queries:

  • query
  • mutation

Reference implementation also adds the third type: subscription. It does not have any semantics yet, so here I would like to propose one possible semantics interpretation and the reasoning behind it.

<?php
chdir(dirname(__DIR__));
require './_autoload.php';
require './_files/initDefaultDatabase.php';
use Zend\Http\Client;
use Zend\Http\Request;
@ClemensSahs
ClemensSahs / layout.phtml
Created October 19, 2012 15:27
Use Prefix or postfix (overwriteable)
<?php
$title = $this->headTitle();
if ( $title->getPrefix() === "" ) {
$title->setPrefix('projekt prefix');
}
echo $this->headTitle();
@ClemensSahs
ClemensSahs / layout.phtml
Created October 19, 2012 15:24
Use Prefix or postfix (simple)
<?php
$this->headTitle()->setPrefix('my view tilte');
echo $this->headTitle();
@ClemensSahs
ClemensSahs / layout_with_append.phtml
Created October 19, 2012 15:15
use headTitle, with append or prepend
<?php
// my view title - my projekt name
$this->headTitle("my projekt name","prepend")
->setSeparator(' - ')->setAutoEscape(false);
?>
<html>
<head>
@ClemensSahs
ClemensSahs / AbstractAdapterServiceFactory.php
Created October 19, 2012 08:50
possible solution: Multiple DB connections with a service locator
namespace Zend\Db\Adapter;
use Zend\Db\Adapter\Exception\InvalidArgumentException;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
/**
* @category Zend
@ClemensSahs
ClemensSahs / gist:3878720
Created October 12, 2012 11:09
check mime type in IANA MIME - DB
/**
* use firebug or a other browser console to exec this script
*
* to create a MimeList set the var(createOnlyMimeList) TRUE
*
* require:
* - jquery
* - browser console ( firebug / chrome )
*
* url: http://www.iana.org/assignments/media-types/index.html
@ClemensSahs
ClemensSahs / example1.php
Created March 9, 2011 06:39
so we change this
public function setRequest($request)
{
if (is_string($request)) {
if (!class_exists($request)) {
throw new Exception('Class is not exists');
}
$request = new $request();
}
if (!$request instanceof Request\AbstractRequest) {
throw new Exception('Invalid request class');