Skip to content

Instantly share code, notes, and snippets.

View benjie's full-sized avatar

Benjie benjie

View GitHub Profile
@benjie
benjie / RELEASE_NOTES_BETA22.md
Last active May 9, 2024 09:36
PostGraphile V5 Beta 22 Release Notes

Release Notes 2024-05-09

This is a huge release, folks! Our last release was 12th Feb, so this covers the 3 month period since then. I finally caught up enough to attack some of the bigger issues in Grafast (specifically the "early exit" and "global dependencies" issues discussed at the first Grafast WG); this has required some breaking changes to the API but as always I've kept these to an absolute minimum; migration steps are outlined below.

@benjie
benjie / JSONL.md
Last active March 18, 2024 10:55
Alternative ways of representing incremental delivery over HTTP

Streamed JSONL

Each payload is just appended as a condensed JSON (no newlines!) payload, with a newline at the end:

HTTP/1.1 200 OK
Content-Type: application/graphql-response+jsonl
Cache-Control: no-cache

{"data":{...},"hasNext":true}
@benjie
benjie / run-in-console.js
Last active February 19, 2024 11:50
GitHub pull request JS snippet to mark all ".mermaid" files as viewed (substitute for any file extension)
((suffix) => {let abort = false; [...$$(`a[title$="${suffix}"]`)].map(el => {const checks = el.parentNode.parentNode.parentNode.querySelectorAll('.js-reviewed-checkbox');if (checks.length !== 1) { throw new Error("Script out of date?");} return checks[0]}).forEach((inpt, i) => setTimeout(() => {if (abort || inpt.checked) return; inpt.click();}, i * 1000))})(".mermaid")
@benjie
benjie / SemanticNonNullSyntax.graphql
Last active February 9, 2024 16:56
Ideas for what the SemanticNonNull syntax could look like
type User {
id: ID!
username: String*
avatarUrl: String
bio: String
friends: [User*]*
}
type User {
id: ID!
username: ~String
@benjie
benjie / graphql@15.5.0.patch
Created December 20, 2023 11:28
Patch for bug in OverlappingFieldsCanBeMergedRule in graphql@^15; apply with `patch-package` or `pnpm patch` or similar.
diff --git a/validation/rules/OverlappingFieldsCanBeMergedRule.js b/validation/rules/OverlappingFieldsCanBeMergedRule.js
index 3fd18139ada7a3e766c78725c8a05ad18a42cddd..ec3cc13ce8efc700f39a4d0fc0f96331b7708906 100644
--- a/validation/rules/OverlappingFieldsCanBeMergedRule.js
+++ b/validation/rules/OverlappingFieldsCanBeMergedRule.js
@@ -180,6 +180,23 @@ function collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFiel
// and any fragment names found in the given fragment.
for (var i = 0; i < fragmentNames2.length; i++) {
+ // Memoize so two fragments are not compared for conflicts more than once.
+ const referencedFragmentName = fragmentNames2[i];
@benjie
benjie / OneOfExploration.md
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:

declare global {
namespace GraphileBuild {
interface PgCodecTags {
// This enables TypeScript autocomplete for our @group smart tag
group?: string | string[];
}
interface Inflection {
// Our inflector to pick the name of the grouped type, e.g. `User` table
// type, and `address` group might produce `UserAddress` grouped type name
groupedTypeName(details: {
@benjie
benjie / npm-wrong-tag.md
Created July 26, 2017 12:16
Resolve publishing npm package to wrong tag

If you accidentally publish a package to the wrong tag (e.g. @latest when you meant to tag it as @next) you can resolve as follows:

npm show PACKAGE_NAME versions # To view the versions you've published
npm dist-tags add PACKAGE_NAME@NEW_VERSION next # Tag the new package version as `@next`
npm dist-tags add PACKAGE_NAME@OLD_VERSION latest # Restore the correct `@latest` to be your previous release version
@benjie
benjie / README.md
Created April 1, 2016 09:15
Easy plv8 on OSX

Heroku runs plv8 v1.4.2 (checked on 1st April 2016). On OSX it's easiest to install v1.4.3 since that allows V8 3.15 which is available via homebrew. (1.4.2 wants V8 3.14.5).

To install:

brew install v8-315
pip install pgxnclient
LIBRARY_PATH="/usr/local/opt/v8-315/lib" CPATH="/usr/local/opt/v8-315/include" pgxnclient install plv8=1.4.3
@benjie
benjie / README.md
Last active January 17, 2023 15:16
Long Live CoffeeScript and Long Live ES6

Long Live CoffeeScript and Long Live ES6

Clearly ES6 is a huge improvement over ES5, and tools like [6to5][] allow us to use these cool features now. I was reading [Replace CoffeeScript with ES6][replace coffeescript] by [Blake Williams][] and thought it was a great summary of how ES6 solves many of the same problems that CoffeeScript solves; however I'd like to comment on a few of Blake's points and talk about why I'll be sticking with CoffeeScript.

Classes

Classes in ES6 (like many of the syntax changes in ES6) are very similar to the CoffeeScript equivalent. To support browsers that are not fully ES5 compliant (e.g. IE8-), however, we still can't really use getters/setters, so ignoring these the comparison is: