Skip to content

Instantly share code, notes, and snippets.

enisdenjo / graphiql-over-ws.html
Last active December 20, 2023 05:32
GraphiQL ❤️ graphql-ws
* Copyright (c) 2021 GraphQL Contributors
* All rights reserved.
* This code is licensed under the MIT license.
* Use it however you wish.
<!DOCTYPE html>
alloy / LiveQueryPolyfill.ts
Last active February 24, 2021 15:09
Rewrite GraphQL Live Query to subscription.
* This is a Live Query polyfill, as graphql-js does not strictly have support for that. Instead, we leave it up to the
* client to recognize a Live Query is requested with the `@live` directive on a `query` operation and here we
* transform it into a `live` subscription instead.
* Consider a schema like the following:
* ```graphql
type Badge {
id: ID!
benjie /
Last active December 4, 2023 14:41
Exploring how `oneOf` could work in a GraphQL schema

oneOf exploration

This document is a work-in-progress exploration of how the "oneOf" solution to input polymorphism might work within a GraphQL schema.

Base schema

For the examples below, we'll be using the following shared types using existing GraphQL syntax:

Jest and the --changedSince flag in GitHub Actions

Recently, I've been working a lot more with GitHub Actions - both writing actions and creating CI pipelines for projects.

Last week I picked up a project I started a bit ago: the nodejs/examples repository.

Note: The examples repository is still in early stages. As such, there's still a bunch of WIP work we're doing - we've intentionally not talked a bunch publicly about it yet. That said, if you're interested in helping, feel free to reach out to me on Twitter or the OpenJS Slack ❤️

The goal of this repository is to be home to a bunch of distinct and well-tested examples of real-world Node.js that go beyond "hello, world!". This means there's hopefully going to be a boatload of distinct projects in there.

bergmannjg /
Last active May 12, 2024 22:33
Building a react native app in WSL2
sibelius / Environment.tsx
Last active October 7, 2022 23:07
Debug Relay Store on Chrome DevTools
const env = new Environment({
handlerProvider: RelayDefaultHandlerProvider,
log: isDev ? relayTransactionLogger : null,
if (isDev) {
window.relayEnvironment = env;
window.debugRelayStore = () =>
acutmore /
Last active January 21, 2024 20:30
Emulating a 4-Bit Virtual Machine in (TypeScript\JavaScript) (just Types no Script)

A compile-time 4-Bit Virtual Machine implemented in TypeScript's type system. Capable of running a sample 'FizzBuzz' program.

Syntax emits zero JavaScript.

type RESULT = VM<
    ["push", N_1],         // 1
    ["push", False],       // 2
 ["peek", _], // 3
n1ru4l / use-reset-State.js
Created August 30, 2019 07:02
const useResetState = (createValue, deps = []) => {
const [, triggerRerender] = useState(createValue);
const stateRef = useRef(NO_VALUE_SYMBOL);
const depsRef = useRef(deps);
if (stateRef.current === NO_VALUE_SYMBOL) {
stateRef.current = createValue();
if (depsRef.current.some((value, index) => value !== deps[index])) {
sibelius / react-scripts+3.0.1.patch
Created July 22, 2019 00:51
react-scripts patch-package to avoid type checking on CRA
diff --git a/node_modules/react-scripts/config/webpack.config.js b/node_modules/react-scripts/config/webpack.config.js
index 8f70442..dfd86d8 100644
--- a/node_modules/react-scripts/config/webpack.config.js
+++ b/node_modules/react-scripts/config/webpack.config.js
@@ -47,6 +47,10 @@ const shouldInlineRuntimeChunk = process.env.INLINE_RUNTIME_CHUNK !== 'false';
// Check if TypeScript is setup
const useTypeScript = fs.existsSync(paths.appTsConfig);
+// Skip TypeScript type checking
+const typeCheckTypeScript =
alfonmga / apollo-refreshToken-link.js
Last active September 5, 2023 22:29
Apollo refresh auth token link. It tries to refresh the user access token on the fly when API throws out an UNAUTHENTICATED error. If multiple requests fail at the same time, it queues them to re-try them later if we are able to get a new access token, otherwise we log out the user and redirect him to the login page.