Skip to content

Instantly share code, notes, and snippets.

View benjie's full-sized avatar

Benjie benjie

View GitHub Profile
const MyPgContextPlugin: GraphileConfig.Plugin = {
name: "MyPgContextPlugin",
description:
"Extends the runtime GraphQL context with details needed to support your configured pgServices",
version: "0.0.0",
grafast: {
middleware: {
prepareArgs(next, { args }) {
if (!args.contextValue) args.contextValue = Object.create(null);
@benjie
benjie / LOCALS_THINGS_TO_CONSIDER.md
Created September 30, 2024 11:43
Things to think about when organising a GraphQL Local

Hosting a GraphQL Local? Here are some things to consider! If you need help with any of these, please do reach out to your contact at the GraphQL Foundation.

  • Do you have a venue?
    • How many people can it safely fit?
    • Does it have specific access requirements? Do you need to register a visitor list ahead of time? Does someone need to be at the door greeting?
    • Is it accessible to people with disabilities?
    • How can people get there using public transport?
    • Is it easy to find?
  • Do you have the necessary equipment to record the talks/hear the speakers?
  • Buying such things are allowed costs for the sponsorship.
@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 / [email protected]
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 / 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
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 / 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")
a = () => () => () => 2;
console.log(a``````);

PostGraphile reproduction script

Hello, you've probably been sent here because you've found an issue in your usage of PostGraphile. I (Benjie) deal with a lot of support requests that have insufficient information for me to diagnose the problem, so I'll ask for a minimal reproduction. Making a minimal reproduction allows me to diagnose (and potentially fix!) the issue much more easily, and is also a valuable exercise for you during your debugging - who knows, maybe whilst attempting to create the reproduction you'll figure out what went wrong and fix your own issue?

To use this, please download the script locally, and then populate the DATABASE