Skip to content

Instantly share code, notes, and snippets.

View nilshartmann's full-sized avatar
🐿️
https://graphql.schule

Nils Hartmann nilshartmann

🐿️
https://graphql.schule
View GitHub Profile
@nilshartmann
nilshartmann / gist:fb68c34a461d922cd86c
Created July 1, 2015 08:37
Using babel browser.js to compile ES6 and JSX code
<!DOCTYPE html>
<html>
<head>
<script src="./react-0.13.3.min.js"></script>
<script src="./browser.min.js"></script>
</head>
<body>
<div id="mount"></div>
</body>
@nilshartmann
nilshartmann / add_bb.sh
Last active August 29, 2015 14:26
Bash function that creates a private BitBucket Repository for your current local Git repository
# Creates a private BitBucket repository with one call from bash
# --------------------------------------------------------------------------------
#
# Uses the BitBucket REST API to create a new private, non-forkable repository
# for the local Git repository your currently staying in.
# The content of your local repository gets pushed after the repository is created.
#
# Prequisites:
# - you must have curl installed
# - your local repo must not have a remote already connect to a bitbucket repo
@nilshartmann
nilshartmann / main.jsx
Created February 28, 2017 10:52
Access React Component using 'ref'
import React from 'react';
import ReactDOM from 'react-dom';
class Input extends React.Component {
constructor() {
super();
this.state = {
greeting: ''
}
}
class Hello {
async greet() {
return new Promise(res => {
setTimeout(() => res("Hallo Welt"), 1000);
});
}
}
const hello = new Hello();
(async () => {
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ApolloClient } from "apollo-client";
import { HttpLink } from "apollo-link-http";
import { InMemoryCache } from "apollo-cache-inmemory";
import { ApolloProvider, withApollo } from "react-apollo";
const apolloClient = new ApolloClient({
@nilshartmann
nilshartmann / README.md
Created April 30, 2018 16:14
Transform Apollo GraphQL Query Types

Currently when using apollo-codegen to generate TypeScript types for query definitions (ts-modern target), the generated types are called as the query name. So if you have a GetUserQuery your basetype is called GetUserQuery.
But in fact the type does not desribe the actual query, but the outcome, the result of the query, so it would be better if the type would have been named like UserQueryResult.

There is an issue in apollo-codegen where this issue is discussed: apollographql/apollo-tooling#315

But as there is currently no progress I wrote a little codemod (using jscodeshift) that renames the types after they have been generated. You can find the transform.js script below.

Color Scheme Generators

Web

@nilshartmann
nilshartmann / graphql-links.md
Created November 12, 2019 08:13
GraphQL Links
@nilshartmann
nilshartmann / Wrapper.jsx
Created March 11, 2020 13:40
sprotty wrapper
class SprottyWrapper {
componentDidMount() {
// Diagramm erzeugen, wie in multicore.ts (hier stark gekürzt:)
this.processor = ...;
const modelSource = container.get<LocalModelSource>(TYPES.ModelSource);
@@ -1,32 +0,0 @@
#! /bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
URL="https://fonts.googleapis.com/css?family=Nunito+Sans:300,300i,400,400i,600,600i,700,700i,800,800i,900,900i&display=swap"
http -p b "${URL}">${DIR}/fonts.css