Skip to content

Instantly share code, notes, and snippets.

@bjunc
bjunc / entity-query.php
Last active August 11, 2017 02:39
lightweight Symfony entity query with alias
// lightweight retrieval of orgId from alias
$em = $this->getDoctrine()->getManager();
$query = $em->createQuery('SELECT org.oid FROM AppBundle:Organization org WHERE org.slug = :alias OR org.oid = :alias')->setParameter('alias', $orgAlias);
$org = $query->getOneOrNullResult();
if (!$org) throw new \Exception('Not Found', 404);
@bjunc
bjunc / graphql-axios.js
Last active January 12, 2024 05:34
application/graphql vs application/json using axios
let input = { first_name: 'Foo', last_name: 'Bar' };
// application/graphql example
/* eslint-disable no-unused-vars */
let configGraphQL = {
url: '/graphql',
method: 'post',
headers: { 'Content-Type': 'application/graphql' },
data: `mutation { user(id: 1, input: ${ JSON.stringify(input) }){ full_name } }`
};