Skip to content

Instantly share code, notes, and snippets.

Avatar
🐿️
https://graphql.schule

Nils Hartmann nilshartmann

🐿️
https://graphql.schule
View GitHub Profile
View function.ts
export default undefined;
type Container<T> = {
consume: (arg: T) => void;
};
// string ist super-type von "hello" 😳
// Entspricht in C# sowas hier:
// public class Event { } // => string
// public class MouseEvent : Event { } // => "hello"
type StringType = string;
@nilshartmann
nilshartmann / DeprecationInstrumentation.java
Last active Sep 10, 2022
Write usage of deprecated GraphQL fields to extensions field and dump on browser console (graphql-java/Spring for GraphQL, Apollo Client)
View DeprecationInstrumentation.java
package nh.publy.backend.util;
import graphql.ExecutionResult;
import graphql.ExecutionResultImpl;
import graphql.execution.instrumentation.InstrumentationContext;
import graphql.execution.instrumentation.InstrumentationState;
import graphql.execution.instrumentation.SimpleInstrumentation;
import graphql.execution.instrumentation.parameters.InstrumentationExecutionParameters;
import graphql.execution.instrumentation.parameters.InstrumentationFieldFetchParameters;
import graphql.schema.GraphQLFieldDefinition;
View BaseError.md
abstract class BaseError {
  private final String message;
  
  public BaseError(String message) { this.message = message; }
  
  public String getMessage() { return this.message; }
}
View graphql-queries-stories.md

Versuche einen Query auszuführen, der die ersten zehn Stories zurückliefert, und folgende Felder abfragt:

Id, Titel, Excerpt, Veröffentlichungsdatum, Wer hat die Story geschrieben und die jeweils ersten zehn Kommentare

query {
  stories(first: 10) {
    nodes {
      id
      title
View install-brew.zsh
#! /bin/zsh
#xcode-select --install
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
View redux-router.md

Routing after handling an action in Redux

Note: this are simplified example, concept only, not correct syntax etc.!

Approach one: use history object in thunk action creator

// my-app-history
View redux-vs-mobx.md

I recently (october 2020) evaluated MobX for a project as alternative to Redux (Redux Toolkit).

You can find my very subjective impressions below.

Redux DevTools better than MobX (for me they were more helpful when finding bugs)

Redux is more widely used than MobX

Change/Dependency tracking in MobX is powerful but not always obvious how it works (both behind the scene and in my application). If values didn't update where I expected it, finding the bug sometimes was hard

View tree-structures-in-redux.md

How to deal with forest/tree structures in a normalized Redux store?

A Redux-based application holds a forest-like data structure, like Folders and Documents in a file system, but with many root Folders, like this:

Folders and Documents

Example Use-Case

In a React Component, DocumentList we display all Documents (all leafs of all trees) and when clicking on one Document, we need access to the Document's root (Folder) object (to read some information from it)

@nilshartmann
nilshartmann / vs-code-vs-intellij-for-typescript-development.md
Last active Mar 14, 2021
Subjective opinions about VS Code and IntelliJ for TypeScript development
View vs-code-vs-intellij-for-typescript-development.md

My very subjective impressions and opinions about VS Code and IntelliJ mainly for TypeScript development.

Note 1: This is not an objective comparison, just a list of points that I noticed when working with the two tools, and which I liked better or worse in each case.

Note 2: For IntelliJ, I used IntelliJ Ultimate Edition 2020.3

Note 3: I have used VS Code for TypeScript much longer than IntellIJ so also for this reason, this is not a "fair" comparison, because many things will turn out only in the long run, if good or bad

Note 4: many/some of the differences maybe could be adjusted by changing settings and/or keyboard shortcuts. And of course by learning the tools better.

@nilshartmann
nilshartmann / upgrade-create-react-app-v4.md
Last active Oct 25, 2020
Upgrade to create-react-app v4
View upgrade-create-react-app-v4.md