Skip to content

Instantly share code, notes, and snippets.

Avatar

ClemensSahs

View GitHub Profile
@ClemensSahs
ClemensSahs / Event-stream based GraphQL subscriptions.md
Created Feb 26, 2017 — forked from OlegIlyenko/Event-stream based GraphQL subscriptions.md
Event-stream based GraphQL subscriptions for real-time updates
View Event-stream based GraphQL subscriptions.md

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.

View test.php
<?php
chdir(dirname(__DIR__));
require './_autoload.php';
require './_files/initDefaultDatabase.php';
use Zend\Http\Client;
use Zend\Http\Request;
@ClemensSahs
ClemensSahs / layout.phtml
Created Oct 19, 2012
Use Prefix or postfix (overwriteable)
View layout.phtml
<?php
$title = $this->headTitle();
if ( $title->getPrefix() === "" ) {
$title->setPrefix('projekt prefix');
}
echo $this->headTitle();
@ClemensSahs
ClemensSahs / layout.phtml
Created Oct 19, 2012
Use Prefix or postfix (simple)
View layout.phtml
<?php
$this->headTitle()->setPrefix('my view tilte');
echo $this->headTitle();
@ClemensSahs
ClemensSahs / layout_with_append.phtml
Created Oct 19, 2012
use headTitle, with append or prepend
View layout_with_append.phtml
<?php
// my view title - my projekt name
$this->headTitle("my projekt name","prepend")
->setSeparator(' - ')->setAutoEscape(false);
?>
<html>
<head>
@ClemensSahs
ClemensSahs / AbstractAdapterServiceFactory.php
Created Oct 19, 2012
possible solution: Multiple DB connections with a service locator
View AbstractAdapterServiceFactory.php
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 Oct 12, 2012
check mime type in IANA MIME - DB
View gist:3878720
/**
* 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
View example1.php
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');