Skip to content

Instantly share code, notes, and snippets.

View hendrikniemann's full-sized avatar
🐯
Rawwwr

Hendrik Niemann hendrikniemann

🐯
Rawwwr
View GitHub Profile
<html>
<head>
<title>Interview Example</title>
</head>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500&family=Space+Grotesk:wght@400;500&display=swap"
@hendrikniemann
hendrikniemann / loadByIdsPlugin.js
Last active November 2, 2020 08:23
React Admin + Postgraphile Data Provider
// TODO: Skip tables without an id field?
module.exports = function LoadByIdsPlugin(builder) {
builder.hook('GraphQLInputObjectType:fields', (fields, build, context) => {
const {
scope: { isPgCondition, pgIntrospection: table },
fieldWithHooks,
} = context;
if (!isPgCondition || !table || table.kind !== 'class') {
return fields;
}
@hendrikniemann
hendrikniemann / ResolveFriends.purs
Last active August 5, 2019 13:18
Medium Post: Why is a pure FP GraphQL implementation so hard to build?
loadCommentsResolver :: Aff Post -> Unit -> Context -> Aff (Array Comment)
loadCommentsResolver affPost args context = affPost >>= \post ->
loadCommentsByPostId post.id context.dbConnection
@hendrikniemann
hendrikniemann / ResolverExample.purs
Last active August 5, 2019 12:59
Medium Post: Why is a pure FP GraphQL implementation so hard to build?
postType :: GraphQL.ObjectType Context (Maybe Post)
postType =
GraphQL.objectType
"Post"
(Just "A blog post that is persisted in the database.")
{ comments:
GraphQL.field
(GraphQL.nonNull $ GraphQL.list $ GraphQL.nonNull GraphQL.string)
(Just "The title of this blog post.")
{ max:
@hendrikniemann
hendrikniemann / index.js
Created January 31, 2019 21:59
Minimal GraphQL Example
const { ApolloServer } = require('apollo-server');
const { GraphQLSchema, GraphQLObjectType, GraphQLString } = require('graphql');
const Query = new GraphQLObjectType({
name: 'Query',
description: 'The query operation entry type.',
fields: {
hello: {
type: GraphQLString,
description: 'Our first query field, how exciting!',
@hendrikniemann
hendrikniemann / schema.graphql
Created February 25, 2018 20:06
Recursive schema definition
type Recursive {
id: ID!
child: Recursive
}
type Query {
recursive: Recursive!
}
@hendrikniemann
hendrikniemann / query.graphql
Last active March 20, 2018 20:05
Recursive query example
query RecursiveExample {
recursive {
id
child {
id
child {
id
}
}
}
@hendrikniemann
hendrikniemann / fragment.graphql
Last active March 6, 2018 17:35
Recursive types GraphQL
fragment RecursiveFragment on Recursive {
id
child {
...RecursiveFragment
}
}
@hendrikniemann
hendrikniemann / install_setlxjs.md
Last active July 29, 2016 12:20
Install SetlX contribution environment

Installing SetlX.js

You can use these scripts to setup SetlX.js for contribution:

Clone this gist into a new folder:

git clone https://gist.github.com/f666bc027e6ed10af9f918d2008a6e12.git setlxjs

switch into the newly created directory:

@hendrikniemann
hendrikniemann / server.js
Last active July 28, 2016 12:00
Webservice Aggregator for foaas.com and randomuser.me
'use strict';
const express = require('express');
const request = require('request-promise');
const FOAAS_URL = 'http://foaas.com/';
const RANDOM_URL = 'http://api.randomuser.me/';
const logError = console.log.bind( console );