profile
viewpoint
Benjie Gillam benjie @graphile Southampton, UK https://graphile.org/sponsor Community-funded OSS developer/maintainer, working in the GraphQL, Node.js and PostgreSQL ecosystems. Maintainer of PostGraphile & related projects. He/him.

benjie/backbone-redis-store 11

NodeJS Backbone mode to enable Redis as data persistence layer

acao/graphiql-1-poc-monaco 2

GraphiQL 1.x POC monaco editor edition

benjie/awesome-postgres 2

A curated list of awesome PostgreSQL software, libraries, tools and resources, inspired by awesome-mysql

benjie/backbone-null-store 2

Null storage engine for Backbone.js

acao/graphiql 1

An in-browser IDE for exploring GraphQL.

benjie/color-diff 1

Implemets the CIEDE2000 color difference algorithm, conversion between RGB and lab color and mapping all colors in palette X to the closest color in palette Y based on the CIEDE2000 difference.

benjie/AFOAuth1Client 0

AFNetworking Extension for OAuth 1.0a Authentication

benjie/ale 0

Asynchronous Lint Engine

startedlesovsky/noisia

started time in a day

issue commentAPIs-guru/graphql-over-http

X-GraphQL-Event-Stream for being notified that the GraphQL schema has updated

Definitely post 1.0 is fine. It’d be optional anyhow.

benjie

comment created time in 2 days

issue commentbenjie/prettier-plugin-pg

Add support for comments

It’s a big ask with the parser how it is; I think a custom parser is they way forward.

benjie

comment created time in 2 days

issue commentbenjie/prettier-plugin-pg

Add support for comments

@rattrayalex The issue relates to knowing the length of the node (so that we know where to insert the comments) rather than choosing what the output should be.

benjie

comment created time in 2 days

push eventbenjie/graphql-spec

Benjie Gillam

commit sha a73d1cc37a55f7cee6c762c99e2c9df201e4e6f0

Change tagged "fields" to "members"

view details

push time in 2 days

issue commentgraphile/worker

Will it work correctly with pgBouncer ?

Currently no, because it uses prepared statements and pgBouncer messes up prepared statements. I'd be open to a PR that makes the prepared statements optional though (just means adding a flag and removing the name from various places, e.g. https://github.com/graphile/worker/blob/f01c70f459085128c445749688f44ac503facb79/src/worker.ts#L88 ).

asafyish

comment created time in 2 days

PR opened graphql/graphql-wg

Add Benjie to July 2020 WG

Sorry for the late PR - was looking at agenda for the live notes link and realised I hadn't added myself! :facepalm:

+1 -0

0 comment

1 changed file

pr created time in 3 days

push eventbenjie/graphql-wg

Benjie Gillam

commit sha a2da4db8443e0abadba878449741e8fc34f92323

Add Benjie to July 2020 WG

view details

push time in 3 days

push eventbenjie/graphql-wg

Benjie Gillam

commit sha 9f82e32f2306fd1cd4420a24543388190d4f4352

Add Benjie to July 2020 WG

view details

push time in 3 days

issue commentAPIs-guru/graphql-over-http

Find the best time for the GraphQL over HTTP working group

Sam I'm not sure the doodle is configured to do what you want it to do? I think you need to separately add 1 or 2 hour slots to it so we can check the slots we can attend.

sjparsons

comment created time in 4 days

pull request commentAPIs-guru/graphql-over-http

Add clarifications regarding HTTP status codes

Generally agreed in working group:

If the server returns GraphQL Content-Type and status code is not 2xx, "data" entry must be either null or not present (depending on if it were an execution error or a validation error)

spawnia

comment created time in 5 days

pull request commentAPIs-guru/graphql-over-http

Add clarifications regarding HTTP status codes

Agreed in working group:

If the server returns GraphQL Content-Type and contains a non-null "data" entry, then it MUST use 2xx status code and it SHOULD use 200 status code.

spawnia

comment created time in 5 days

push eventgraphile/graphile.github.io

Tolli

commit sha d852932d0fabf0ec76c13489fa8535dc8ac01df2

Fix channel-name-being-a-heading Word wrapping caused `#help-and-support` to be at the beginning of a line rendering it as a heading.

view details

Benjie Gillam

commit sha c7751b5d5ade65a05aa1b94958b95891bad9be26

Tweak

view details

Benjie Gillam

commit sha 62385ae883d2e1980099687cec242681a6535a04

Merge pull request #232 from Tolli81/patch-1

view details

push time in 5 days

PR merged graphile/graphile.github.io

Fix channel-name-being-a-heading

Word wrapping caused #help-and-support to be at the beginning of a line rendering it as a heading.

+1 -1

0 comment

1 changed file

Tolli81

pr closed time in 5 days

push eventTolli81/graphile.github.io

Benjie Gillam

commit sha c7751b5d5ade65a05aa1b94958b95891bad9be26

Tweak

view details

push time in 5 days

issue commentgraphile/worker

Add multiple leaky bucket rate limiting

I think it'd be appropriate to handle this within the jobs themselves rather than adding more logic to the database. I'd make the job definition something like (PSEUDOCODE!)

const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
const MESSAGES_PER_MINUTE = 3000;
const MESSAGES_PER_SECOND_PER_NUMBER = 6;
const AVERAGE_DELAY_IN_MILLISECONDS = 1000;
const MIN_DELAY_IN_MILLISECONDS = 100;
const MAX_ATTEMPTS = 20; // We'll try to find a send slot this many times.
                         // With these values, it'll take on average 22 seconds
                         // to exhaust attempts.

// This is the real task, sans rate limiting
const performSend = async (payload, helpers) => {
  // Example:
  await sms.send(payload.number, payload.message);
}

// This does the rate limiting then hands off to the above function for execution
const task = async (payload, helpers) => {
  const number = payload.number; // e.g. '+441234567890';

  for (let attempts = 0; attempts < MAX_ATTEMPTS; attempts ++) {
    // Check the number counter first; if this is allowed but the main limit is exceeded,
    // then the global limit will not be permitted _ever_ during this second so we're
    // not blocking anything.
    const numberCounter = `${number}|${Math.floor(Date.now()/1000)}`;
    if (await isCounterLessThan(numberCounter, MESSAGES_PER_SECOND_PER_NUMBER, 1)) {
      // Now check the global counter.
      const globalCounter = `global|${Math.floor(Date.now()/60000)}`;
      if (await isCounterLessThan(globalCounter, MESSAGES_PER_MINUTE, 60)) {
        // Do it! We're returning here so the loop stops and error is not thrown.
        return performSend(payload, helpers);
      }
    }
  
    // Try again once the slots have moved on
    await sleep(
      MIN_DELAY_IN_MILLISECONDS +
      Math.ceil(Math.random() * 2 * AVERAGE_DELAY_IN_MILLISECONDS)
    );
  }
  throw new Error("Attempts exceeded; try again later");
}

async function isCounterLessThan(counterName, limit, validityPeriodInSeconds) {
  // Advance the counter
  const val = await redis.incr(counterName, 1);
  // Make sure counter self-destructs
  await redis.expire(counterName, validityPeriodInSeconds + 60 /* allow for clock skew */);
  // Was the counter less than limit?
  return val <= limit;
}

There's some issues around latency in this - if latency is variable then there's a chance that messages per second may be high one second and low next - but I expect they actually use a rolling average so this should sort itself out.

With this, you'd want high concurrency (since you spend a hell of a lot of time waiting) and you don't really need a queue name. Having concurrency above the pg pool size would be completely fine for this, despite the warnings it raises.

What do you think?

I worry that because scheduling and execution are independent, performing leaky bucket at scheduling time would not be very good because if you ever scale your workers down all jobs might well be executed in a massive batch when the workers scale back up again. Performing leaky bucket at execution time in Postgres would probably slow the queue down and put more load on the DB.

I'd be well up for somehow making the above algorithm something you can automatically wrap tasks with; we've talked about task wrappers before and this is just the kind of thing they'd be great for.

ben-pr-p

comment created time in 5 days

issue commentgraphile/postgraphile

Provide a callback function to handle serious errors

Discussion in #1302

benjie

comment created time in 5 days

pull request commentgraphile/postgraphile

Feat/handle serious error

What is the desired behaviour you're going for? At the moment, this seems to result in a response of {"errors":[{}]} due to a bug in the handling of non-GraphQLError errors here:

https://github.com/graphile/postgraphile/blob/66c2b4a3713cacd0abb891cb813d45d07b7f6ba3/src/postgraphile/http/createPostGraphileHttpRequestHandler.ts#L862

You've asked in #1073 why PostGraphile has retry logic* rather than letting the infrastructure level handle it, but by default PostGraphile does let the infrastructure level handle it ─ by exiting the process, the infrastructure can perform a (delayed) restart. I guess you're thinking more of a "health-check" style infrastructure approach, where the infra pings the GraphQL API with something harmless such as the {__typename} query and if it receives errors it restarts? Or do you have something else in mind.

* We have retry logic because it's a common request from people running PostGraphile with Docker, and because PostGraphile is often not the only middleware you're using, and because a temporary outage of the PostgreSQL server should not prevent the rest of your server from running.

I'd love to understand more about your setup and exactly what your desired behaviour is so that I can analyse this PR better. Currently you've taken a function that was designed to never reject and made it possibly reject indirectly (via the throw example), but I'm not sure what your intentions are beyond that.

pyramation

comment created time in 5 days

push eventgraphile/starter

Luke Ramsden

commit sha 46134bf2d127ae46661edaf80a811a4332e9bc9d

Fixed db dump command (#177)

view details

push time in 5 days

PR merged graphile/starter

Fixed db dump command
+1 -1

0 comment

1 changed file

lukeramsden

pr closed time in 5 days

issue commentgraphile/starter

Add worker 'install-db-schema' to Heroku setup template

You raise a good point; we currently use afterReset to install the schema; but that'll only do it on the first version and won't install updates until the worker itself runs properly. We should instead use the beforeAllMigrations hook (which is newer than the configuration file, I think).

https://github.com/graphile/starter/blob/7ebee843e3d0d4dc827fd1f8902f10d16b014b45/%40app/db/.gmrc#L71

PR welcome :+1:

zacherkkila

comment created time in 5 days

PR opened APIs-guru/graphql-over-http

Add Benjie to June WG

Sorry for lateness, missed this (just saw it in Slack).

+1 -0

0 comment

1 changed file

pr created time in 5 days

push eventbenjie/graphql-over-http

Benjie Gillam

commit sha 9079be01ecb94d6dc5ba1cb7d4dec20427e5861d

Add Benjie to June WG

view details

push time in 5 days

push eventgraphile/graphile.github.io

John Jannotti

commit sha be62823e2c1598fd5f0594246950e1affa438561

Update required-knowledge.md

view details

push time in 7 days

PR merged graphile/graphile.github.io

Update required-knowledge.md

Just a typo correction

+1 -1

0 comment

1 changed file

jannotti

pr closed time in 7 days

PullRequestEvent

PR closed graphile/graphile.github.io

Update required-knowledge.md

Just a typo correction

+1 -1

0 comment

1 changed file

jannotti

pr closed time in 7 days

Pull request review commentremirror/remirror

feat: realtime collaborative editing

+import {+  CustomHandlerKeyList,+  DefaultExtensionOptions,+  HandlerKeyList,+  PlainExtension,+  StaticKeyList,+  convertCommand,+  invariant,+} from '@remirror/core';+import { redo, undo, yCursorPlugin, ySyncPlugin, yUndoPlugin } from 'y-prosemirror';+import { Doc } from 'yjs';+import { WebrtcProvider } from 'y-webrtc';+import { Observable } from 'lib0/observable';+import { css } from 'linaria';++/**+ * yjs typings are very rough; so we define here the interface that we require

Awesome :raised_hands:

benjie

comment created time in 9 days

Pull request review commentremirror/remirror

feat: realtime collaborative editing

+import {+  CustomHandlerKeyList,+  DefaultExtensionOptions,+  HandlerKeyList,+  PlainExtension,+  StaticKeyList,+  convertCommand,+  invariant,+} from '@remirror/core';+import { redo, undo, yCursorPlugin, ySyncPlugin, yUndoPlugin } from 'y-prosemirror';+import { Doc } from 'yjs';+import { WebrtcProvider } from 'y-webrtc';+import { Observable } from 'lib0/observable';+import { css } from 'linaria';++/**+ * yjs typings are very rough; so we define here the interface that we require

Awesome; Ifi was planning to contribute back some improved typings, but good to know they’re available soon! We need a “provider” type that all providers implement (webrtc, websockets), is there such a thing, @dmonad?

benjie

comment created time in 10 days

issue commentgraphile/postgraphile

Generating Lists From Table Column With Simple Collection

Indeed; you can achieve that with a custom query or a plugin 👍

git-blame

comment created time in 10 days

push eventgraphile/starter

John Jannotti

commit sha 7ebee843e3d0d4dc827fd1f8902f10d16b014b45

Fixup some documentation urls that still refer to "master" branch (#176) * Fixup some documentation urls that still refer to "master" branch * Inadvertently changed - antd has not renamed master

view details

push time in 10 days

PR merged graphile/starter

Fixup some documentation urls that still refer to "master" branch

some links were broken because they referred to "master"

+5 -5

0 comment

3 changed files

jannotti

pr closed time in 10 days

pull request commentgraphql/graphiql

feat(merge): make fragment merging type-aware

Awesome; merge at will. Most ASTs don’t contain comments (they’re generally skipped by the lexer as if they were whitespace) but it’d certainly be a welcome addition.

benjie

comment created time in 10 days

Pull request review commentgraphql/graphql-js

Change type of extensions from anonymous Record to named interfaces

  const path = require('path'); const childProcess = require('child_process');+const assert = require('assert');+const fs = require('fs');+const glob = require('glob');+const semver = require('semver');  const { dependencies } = require('./package.json');  const tsVersions = Object.keys(dependencies)   .filter((pkg) => pkg.startsWith('typescript-'))   .sort((a, b) => b.localeCompare(a)); +// To allow omitting certain code from older versions of TypeScript, we have a+// "magic" comment syntax. We precede a block of code with:+//+//     /*! SEMVER_RANGE !*/+//+// replacing SEMVER_RANGE with a semver range spec, such as '>=3.2'; we+// terminate the block of code with:+//+//     /*!!*/+//+// We will only include the code between these comments if the TypeScript+// version being tested satisfies the semver range that was specified. NOTE: We+// currently do not allow nesting of these blocks.+const templates = glob.sync('./*.ts.template').map((filename) => {+  const content = fs.readFileSync(filename, 'utf8');+  const targetFilename = filename.replace(/\.template$/, '');+  assert.notEqual(filename, targetFilename);+  const writeFileSync = (version) => {+    // Captures our magic comment syntax: `/*!(CAPTURE1)!*/(CAPTURE 2)/*!!*/`+    const regex = /\/\*!([^!]+)!\*\/([\s\S]*?)\/\*!!\*\//g;+    const finalContent = content.replace(regex, (_, versionRange, payload) => {+      if (semver.satisfies(version, versionRange)) {+        return payload;+      } else {+        return '';+      }+    });+    fs.writeFileSync(targetFilename, finalContent);+  };+  return { writeFileSync };+});+ for (const version of tsVersions) {   console.log(`Testing on ${version} ...`); +  for (const template of templates) {+    template.writeFileSync(version);+  }+
  1. You already have a lot of dependencies on both of these modules according to package-lock.json, but I totally get where you're coming from
  2. Great :+1:
  3. Okay.

I've reverted the commit that adds this testing support.

benjie

comment created time in 10 days

push eventbenjie/graphql-js

Benjie Gillam

commit sha b33e65fb97dedbe9216cdef33d8df743c170d538

Revert "Allow testing certain code blocks on only specific TypeScript versions" This reverts commit 04c837a6caa3661bc317be33a7ef896ae51d2183.

view details

push time in 10 days

push eventbenjie/graphql-js

Benjie Gillam

commit sha 04c837a6caa3661bc317be33a7ef896ae51d2183

Allow testing certain code blocks on only specific TypeScript versions

view details

Benjie Gillam

commit sha 15407be37753279ebf98c26f7f11cfbf2c1842d2

Revert "Allow testing certain code blocks on only specific TypeScript versions" This reverts commit 04c837a6caa3661bc317be33a7ef896ae51d2183.

view details

push time in 10 days

pull request commentgraphql/graphql-js

Add parentType to path to avoid path ambiguity

Suggestion merged; I have not corrected all the other places in the file that use execute rather than executeSync.

benjie

comment created time in 10 days

push eventbenjie/graphql-js

Benjie Gillam

commit sha 02827d0eda0b0f675d24ac8df963f2dca642f01e

Update src/execution/__tests__/executor-test.js Co-authored-by: Ivan Goncharov <ivan.goncharov.ua@gmail.com>

view details

push time in 10 days

pull request commentgraphql/graphiql

feat(merge): make fragment merging type-aware

unfortunately there isn't a way to test this yet since the merge capability was amongst what was temporarily disabled

That's okay; we still pass the unit tests (which I've re-enabled and expanded), so we can be pretty confident that it'll still work at least as well as the old version did:

From CI: PASS graphiql packages/graphiql/src/utility/__tests__/mergeAst.spec.ts

maybe also a test to confirm that it preserves comments? that's been a highly requested feature

It does not preserve comments; neither does the old version. Yes this would be nice; but it's an entirely different body of work out of scope of this PR (AFAIK the AST doesn't include comments, so we'd need to grab these from the source and then some how re-apply them at the end like prettier does; this is quite an undertaking). Also it poses its own challenges about how comments should be merged.

benjie

comment created time in 10 days

push eventremirror/remirror

Benjie Gillam

commit sha d2ce9b278e4582bc2241eb005e98531b349e6cb2

fix(yjs): cleaner cleanup

view details

Benjie Gillam

commit sha 8a32faa0fd24563b947c4055a983d704287792c8

docs(gitattributes): add note about generated files

view details

push time in 10 days

pull request commentremirror/remirror

Realtime editing demo

This PR has been replaced by https://github.com/remirror/remirror/pull/319 - thanks for your guidance @dmonad!

benjie

comment created time in 10 days

PR closed remirror/remirror

Realtime editing demo

Description

Adds an example of how to use realtime prosemirror editing using yjs's prosemirror support and the websocket transport.

I'd like some guidance on how best to achieve this to Remirror. It works, but it's pretty flaky.

Checklist

  • [x] I have read the contributing document.
  • [x] My code follows the code style of this project and yarn fix runs successfully.
  • [x] I have updated the documentation where necessary.
  • [x] New code is unit tested and all current tests pass when running yarn test .

Screenshots

Peek 2020-02-20 15-54

+845 -456

5 comments

9 changed files

benjie

pr closed time in 10 days

pull request commentremirror/remirror

feat: realtime collaborative editing

We have it working with other extensions too!!

Peek 2020-06-25 17-05

benjie

comment created time in 10 days

push eventremirror/remirror

Benjie Gillam

commit sha 6ad3c247f60de1bd5a877b73afd5cc3f8031b35a

fix(playground): fix unmounting in Execute

view details

Benjie Gillam

commit sha f8f8a801d6d815c0401fd75c17428e0c64f23128

fix(use-manager): ensure manager is destroyed

view details

Benjie Gillam

commit sha e1f6e27754199518392088b6bbf88895916e4bbb

Code and requires must remain in sync

view details

Benjie Gillam

commit sha 96169ecaac7f2f0176c19a1d2fea6ca983b40bea

fix(destroy): don't dispatch transactions after manager is destroyed

view details

Benjie Gillam

commit sha 8abf14fba5c06810548cfe0d195e98b685cfbba2

fix(yjs): disconnect from provider on destroy

view details

Benjie Gillam

commit sha e1e8b50d7a66126bc003106d37c070b2f2412b29

fix(yjs): friendlier (and more correct) cleanup

view details

push time in 10 days

PR opened remirror/remirror

feat: realtime collaborative editing

Description

This PR replaces #238; adding yjs support for the new Remirror. This can be demonstrated with the following code in the playground (advanced mode):

import React, { FC } from "react";
import { YjsExtension } from "remirror/extension/yjs";
import { RemirrorProvider, useManager, useRemirror } from "remirror/react";

const EXTENSIONS = [new YjsExtension()];

/**
 * This component contains the editor and any toolbars/chrome it requires.
 */
const SmallEditor: FC = () => {
  const { getRootProps } = useRemirror();

  return (
    <div>
      <div {...getRootProps()} />
    </div>
  );
};

const SmallEditorWrapper = () => {
  const extensionManager = useManager(EXTENSIONS);

  return (
    <RemirrorProvider
      manager={extensionManager}
    >
      <SmallEditor />
    </RemirrorProvider>
  );
};

export default SmallEditorWrapper;

As recommended by @dmonad in #238 we've switched over to y-webrtc so that the editing Just Works :tm: rather than requiring an external server.

Checklist

  • [x] I have read the contributing document.
  • [ ] My code follows the code style of this project and pnpm run fix completed successfully.
  • [ ] I have updated the documentation where necessary.
  • [ ] New code is unit tested and all current tests pass when running pnpm run test .

Screenshots

Peek 2020-06-25 15-14

Future tasks

  • [ ] Make work as controlled component
  • [ ] Allow configuring the provider (e.g. to use different channels)
  • [ ] In playground, allow setting the channel as part of the URL/config so can copy URL and send to a collaborator.
+3558 -3089

0 comment

17 changed files

pr created time in 10 days

create barnchremirror/remirror

branch : next-yjs

created branch time in 10 days

push eventgraphql/graphiql

Rikki Schulte

commit sha 2652f55894dde2aad4ce92baa50d85484909211e

docs: setSchema typo (#1595)

view details

Benjie Gillam

commit sha 9d04c2aabd0db2b671272e17c77bbd8dcef5ed41

chore(test): set up for monorepo test running (#1594)

view details

Benjie Gillam

commit sha 3ab04fb7d831a8d960611095f0135a03e3941af9

feat(merge): make fragment merging type-aware

view details

Benjie Gillam

commit sha 8f1ac694ec2290422767afd3b9ea2a221b326f98

fix(merge-ast): allow mergeAst without schema

view details

Benjie Gillam

commit sha 8c4b1c7a3492b969e682c25908e721c7fd732903

feat(merge-asts): ability to merge duplicate spreads

view details

Benjie Gillam

commit sha b39e501b06042f935d6816ec300f2e1664517556

chore(tests): re-enable GraphiQL utils tests

view details

Benjie Gillam

commit sha ea276ad0f1c1c01f4847592d279fc05c944f3e60

chore(tests): test mergeAst with schema knowledge

view details

Benjie Gillam

commit sha c160a3008c39a6fcff9e3add16d2dc0d8daabadc

chore(types): fix type

view details

push time in 10 days

push eventgraphql/graphiql

Benjie Gillam

commit sha ea1f85a3b18f37b930289b616949e3f3c893067c

chore(types): fix type

view details

push time in 10 days

pull request commentgraphql/graphiql

chore(test): set up for monorepo test running

The main advantage is allowing per-project configuration when desired. In particular you currently have graphiql and codemirror-graphql entirely disabled in the root config which makes it incredibly difficult to run their tests; with this approach you can instead configure those projects to run only the tests you wish to allow without making your configuration complex for other projects.

benjie

comment created time in 11 days

pull request commentgraphql/graphiql

chore(test): set up for monorepo test running

To be clear; this approach allows you to run the tests from the root and, should you desire, also from the package. I've only ran them from the root so far, and it works great:

Screenshot_20200624_163652

benjie

comment created time in 11 days

push eventgraphql/graphiql

Benjie Gillam

commit sha e46dc67f4af24c2fc845b6bdee53e28cd81d8a20

chore(test): set up for monorepo test running

view details

Benjie Gillam

commit sha dd3e94458b4ab9bce67991e7c5efd0f69915d48c

feat(merge): make fragment merging type-aware

view details

Benjie Gillam

commit sha 173bce3f495903d35feccb95319bb1f472981359

fix(merge-ast): allow mergeAst without schema

view details

Benjie Gillam

commit sha ded653b6c6b6b394bd9a59ab702068f157b6e55e

feat(merge-asts): ability to merge duplicate spreads

view details

Benjie Gillam

commit sha e703ec5efb0770b0304f84c2bcdd32f9e7490728

chore(tests): re-enable GraphiQL utils tests

view details

Benjie Gillam

commit sha 8611296993150912ab7eee48a8f9174d6f1fca45

chore(tests): test mergeAst with schema knowledge

view details

push time in 11 days

PR opened graphql/graphiql

Reviewers
chore(test): set up for monorepo test running

Whilst working on #1542 I noticed it's a bit of a pain to run tests right now. This PR sets the repo up for easy jest test running; each package can have it's own configuration, optionally based on the base configuration. The root jest.config.js is just responsible for loading all these other projects.

You'll notice that I've replaced <rootDir> with ${__dirname} in various places, because <rootDir> now refers to each of the package roots rather than the repo root.

You'll also note that I removed the testPathIgnorePatterns: ['codemirror-graphql','packages/graphiql'] in favour of having those projects configure their own test matches (in this case, matching nothing).

I have NOT checked that code coverage still works; that's the one thing that may need some more scrutiny. Other than this, I think this change is completely uncontroversion and highly beneficial :)

+78 -53

0 comment

13 changed files

pr created time in 11 days

create barnchgraphql/graphiql

branch : monorepo-testing

created branch time in 11 days

push eventgraphql/graphiql

SToneX

commit sha 1bb7b0e7f8f265a52092bae4dd93809e78ba3b83

fix: remove @ts-nocheck and fix type errors (#1541)

view details

Harshith Pabbati

commit sha e54e1a8691483f1d336231314130d9822481b3be

fix: trigger edit variables on first render (#1545)

view details

Rikki Schulte

commit sha d77679970ea5a9d902d9c4031ece9cf2d67d8869

improvement: cleaner types for monaco-graphql (#1549)

view details

Rikki Schulte

commit sha 07df06057d36f6491499e830f7e2f204d2549644

docs: version notices for the GraphiQL readme (#1554)

view details

Rikki Schulte

commit sha 63bc78de964d5fa8973460626db9f02ed4c09d0d

chore: fix monaco types for SchemaConfig (#1555)

view details

jmgr2996

commit sha f85969c7e77e8fd269e026be36cc5065d6d33237

fix: Safe setState (#1547) Co-authored-by: Juan Mateo Garcia Ramirez <juanmateo.garcia@globant.com>

view details

Haroen Viaene

commit sha 4d79f2c028ecc5ccf0dd3ecba54a3c669cfd0cf8

docs: remove copy/paste artifact (#1556)

view details

Connor Shea

commit sha 3faa1ac46514252e90abf2b2bda0841edf6115ea

feat: Add Headers Editor to GraphiQL (#1543) Co-authored-by: Rikki Schulte <rikki.schulte@gmail.com>

view details

Rikki

commit sha c1afc2eae6de740983d960e92d2df5e5f17270e8

chore(release): publish - example-graphiql-create-react-app@0.1.3 - graphiql-parcel-example@1.1.2 - example-graphiql-webpack@1.0.0-alpha.11 - example-monaco-graphql-webpack@1.0.0-alpha.6 - codemirror-graphql@0.12.0-alpha.9 - graphiql@1.0.0-alpha.11 - graphql-language-service-cli@3.0.0-alpha.3 - graphql-language-service-interface@2.4.0-alpha.9 - graphql-language-service-server@2.4.0-alpha.10 - graphql-language-service@3.0.0-alpha.2 - monaco-graphql@0.1.2

view details

Rikki

commit sha b703b67d1d4f515108898d3f4c42b9bd1462c2ef

improvement: always target es5 except for node

view details

Rikki

commit sha 9b9331efd06a724725af6b394cc3e1cff467019b

fix: ignore tsbuild cache to reduce npm size

view details

Rikki

commit sha 4a2621808a1aea8b30d5d27b8d86a60bf2b44b01

fix: cleanup cache entry from lerna publish

view details

harshithpabbati

commit sha ce7b2e2b45d530b61e916112e864074cf3a6ddc7

fix: display variable editor when headers are not enabled

view details

Yoshi Sukeda

commit sha cea837ff77c36dadb01b4302282821b00d7f5f2f

fix: make list type and non-nullable type available (#902) Co-authored-by: Rikki <rikki.schulte@gmail.com> Co-authored-by: Yoshiakis <yoshisukeda@yahoo.com>

view details

Yoshi Sukeda

commit sha f39f5855c8716e7d4f6157fd3d1ed5d4044450c1

test: fix test cases for codemirror-graphql (#1563)

view details

Rikki

commit sha fe284b930bdc65328ddc44f1cfa0ecf613352983

chore(release): publish - example-graphiql-create-react-app@0.1.4 - graphiql-parcel-example@1.1.3 - example-graphiql-webpack@1.0.0-alpha.12 - example-monaco-graphql-webpack@1.0.0-alpha.7 - codemirror-graphql@0.12.0-alpha.10 - graphiql@1.0.0-alpha.12 - graphql-language-service-cli@3.0.0-alpha.4 - graphql-language-service-interface@2.4.0-alpha.10 - graphql-language-service-parser@1.6.0-alpha.5 - graphql-language-service-server@2.4.0-alpha.11 - graphql-language-service-types@1.6.0-alpha.7 - graphql-language-service-utils@2.4.0-alpha.8 - graphql-language-service@3.0.0-alpha.3 - monaco-graphql@0.1.3

view details

Rikki

commit sha 9ce01b17e5046cf12fba89146cbf70df84d3d6af

chore(release): publish - example-graphiql-cdn@0.0.8-alpha.6 - example-graphiql-create-react-app@0.1.5 - graphiql-parcel-example@1.1.4 - example-graphiql-webpack@1.0.0-alpha.13 - example-monaco-graphql-webpack@1.0.0-alpha.8 - codemirror-graphql@0.12.0-alpha.11 - graphiql@1.0.0-alpha.13 - graphql-language-service-cli@3.0.0-alpha.5 - graphql-language-service-interface@2.4.0-alpha.11 - graphql-language-service-parser@1.6.0-alpha.6 - graphql-language-service-server@2.4.0-alpha.12 - graphql-language-service-types@1.6.0-alpha.8 - graphql-language-service-utils@2.4.0-alpha.9 - graphql-language-service@3.0.0-alpha.4 - monaco-graphql@0.1.4

view details

Yoshi Sukeda

commit sha 39c00a55d7af43ce4e57ad9b1d5cd55393beb0d0

fix: value of documentation in completion list (#1567)

view details

Thomas Rich

commit sha cc7fbfe89d65943f23f58187c3fa3bdf0d4bbf1d

fix: highlightNode xxx in xxx syntax to revert back to simple dot notation for checking of existence (#1566)

view details

Harshith Pabbati

commit sha 046b09f541e6a9f2ce4b46de590d49c04c916716

fix: Move all componentWillUnMount functionality to respective events (#1544) Co-authored-by: Rikki Schulte <rikki.schulte@gmail.com>

view details

push time in 11 days

issue closedgraphile/postgraphile

Generating Lists From Table Column With Simple Collection

I'm submitting a ... <!-- check one with "x" -->

  • [ ] bug report
  • [ ] feature request
  • [x] question <!-- alternatively, ask on Discord (http://discord.gg/graphile) -->

PostGraphile version: 4.5.5

Looking over "simple collection" documentation, there is this statement:

for example if you want relay connections for almost all collections, except when it comes to a user's email addresses where you want to use a simple list

The doc implies that there are 2 tables: user, email and a foreign key constraint user_id on email.

This seems to indicate for a user, you can get an "array" of the user's email addresses (ie, "email": ["a@home, "b@work"]). But I don't know if I'm misinterpreting simple collection functionality.

Before I try to use smart comment, I enabled --simple-collections both to test.

artifacts resultsartifacts
id (pkey) id (pkey), artifactid (foreign key on artifacts), resultid

Query:

{
  allArtifacts(condition: {rowId: "16"}, orderBy: ID_ASC) {
    nodes {
      aid: rowId
      result: resultsartifactsByArtifactidList {
        resultid
      }
    }
  }
}

yields:

{
  "data": {
    "allArtifacts": {
      "nodes": [
        {
          "aid": "16",
          "result": [
            {
              "resultid": "16"
            },
            {
              "resultid": "17"
            },
 ...

This output list is close (though it really only removed the extra nodes field if I used instead resultsartifactsByArtifactid). I was hoping for "result": [ "16", "17", ... ].

Is this even possible with simple collections (for example, via smart comments)? Or would I need to do something else such as computed column function, etc.?

I'm trying to understanding how simple collection output differs from standard connection results. To get a "simple list" (like the email addresses in the documentation), do you need a function that returns a set/list of non-record values (e.g. int, string)? If so, I'm not sure what simple collection means when applied to a table or view (except that you don't have to specify "nodes" in your query).

closed time in 11 days

git-blame

issue commentgraphile/postgraphile

Generating Lists From Table Column With Simple Collection

Assuming you have:

type User {
  id: Int!
  username: String!
  name: String
}

Simple collections defines a simple list of the relevant type:

expand type Query {
  # This is a simple collection
  allUsersList: [User!]
}

However, Relay Connections introduces a heirarchy of new types; something like:

type PageInfo {
  hasNextPage: Boolean
  hasPreviousPage: Boolean
  firstCursor: Cursor
  lastCursor: Cursor
}

type UserEdge {
  node: User
  cursor: Cursor
}

type UserConnection {
  edges: [UserEdge!]
  nodes: [User!]
  pageInfo: PageInfo
  totalCount: Int
}

expand type Query {
  # This is a GraphQL connection
  allUsers: UserConnection
}

Simple collections cannot convert an object such as User into a scalar. User's email addresses might be something like:

"""Information about a user's email address."""
type UserEmail {
  createdAt: Datetime!

  """The users email address, in `a@b.c` format."""
  email: String!

  id: UUID!

  isPrimary: Boolean!

  """
  True if the user has is_verified their email address (by clicking the link in
  the email we sent them, or logging in with a social login provider), false otherwise.
  """
  isVerified: Boolean!

  updatedAt: Datetime!

  """Reads a single `User` that is related to this `UserEmail`."""
  user: User

  userId: UUID!
}

If you want to return a scalar list, e.g. [Int], then you could achieve this with computed columns or makeExtendSchemaPlugin or others.

Have a read of the Introduction to GraphQL; in particular it seems that a stronger understanding of the GraphQL Type System might help answer this question.

[semi-automated message] Thanks for your question; hopefully we're well on the way to helping you solve your issue. This doesn't currently seem to be a bug in the library so I'm going to close the issue, but please feel free to keep requesting help below and if it does turn out to be a bug we can definitely re-open it 👍

You can also ask for help in the #help-and-support channel in our Discord chat.

git-blame

comment created time in 11 days

push eventgraphile/postgraphile

dependabot[bot]

commit sha 66c2b4a3713cacd0abb891cb813d45d07b7f6ba3

chore(deps): bump websocket-extensions in /postgraphiql (#1304) Bumps [websocket-extensions](https://github.com/faye/websocket-extensions-node) from 0.1.3 to 0.1.4. - [Release notes](https://github.com/faye/websocket-extensions-node/releases) - [Changelog](https://github.com/faye/websocket-extensions-node/blob/master/CHANGELOG.md) - [Commits](https://github.com/faye/websocket-extensions-node/compare/0.1.3...0.1.4) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

view details

push time in 11 days

delete branch graphile/postgraphile

delete branch : dependabot/npm_and_yarn/postgraphiql/websocket-extensions-0.1.4

delete time in 11 days

PR merged graphile/postgraphile

chore(deps): bump websocket-extensions in /postgraphiql dependencies

Bumps websocket-extensions from 0.1.3 to 0.1.4. <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/faye/websocket-extensions-node/blob/master/CHANGELOG.md">websocket-extensions's changelog</a>.</em></p> <blockquote> <h3>0.1.4 / 2020-06-02</h3> <ul> <li>Remove a ReDoS vulnerability in the header parser (CVE-2020-7662, reported by Robert McLaughlin)</li> <li>Change license from MIT to Apache 2.0</li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/faye/websocket-extensions-node/commit/8efd0cd6e35faf9bb9cb08759be1e27082177d43"><code>8efd0cd</code></a> Bump version to 0.1.4</li> <li><a href="https://github.com/faye/websocket-extensions-node/commit/3dad4ad44a8c5f74d4f8f4efd3f9d6e0b5df3051"><code>3dad4ad</code></a> Remove ReDoS vulnerability in the Sec-WebSocket-Extensions header parser</li> <li><a href="https://github.com/faye/websocket-extensions-node/commit/4a76c75efb1c5d6a2f60550e9501757458d19533"><code>4a76c75</code></a> Add Node versions 13 and 14 on Travis</li> <li><a href="https://github.com/faye/websocket-extensions-node/commit/44a677a9c0631daed0b0f4a4b68c095b624183b8"><code>44a677a</code></a> Formatting change: {...} should have spaces inside the braces</li> <li><a href="https://github.com/faye/websocket-extensions-node/commit/f6c50aba0c20ff45b0f87cea33babec1217ec3f5"><code>f6c50ab</code></a> Let npm reformat package.json</li> <li><a href="https://github.com/faye/websocket-extensions-node/commit/2d211f3705d52d9efb4f01daf5a253adf828592e"><code>2d211f3</code></a> Change markdown formatting of docs.</li> <li><a href="https://github.com/faye/websocket-extensions-node/commit/0b620834cc1e1f2eace1d55ab17f71d90d88271d"><code>0b62083</code></a> Update Travis target versions.</li> <li><a href="https://github.com/faye/websocket-extensions-node/commit/729a4653073fa8dd020561113513bfa2e2119415"><code>729a465</code></a> Switch license to Apache 2.0.</li> <li>See full diff in <a href="https://github.com/faye/websocket-extensions-node/compare/0.1.3...0.1.4">compare view</a></li> </ul> </details> <br />

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


<details> <summary>Dependabot commands and options</summary> <br />

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
  • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
  • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
  • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the Security Alerts page.

</details>

+3 -3

0 comment

1 changed file

dependabot[bot]

pr closed time in 11 days

Pull request review commentAPIs-guru/graphql-over-http

Add clarifications regarding HTTP status codes

 The result of executing a GraphQL operation may contain partial data as well as Errors that happen during execution of the GraphQL operation typically become part of the result, as long as the server is still able to produce a well-formed response. -In case of errors that completely prevent the successful execution of the request, the server SHOULD respond-with the appropriate status code depending on the concrete error condition. For example:+In case of errors that completely prevent the successful execution of the request, the server MUST respond+with the appropriate status code depending on the concrete error condition. -- `400` (Bad Request), in case of a validation error-- `401` (Unauthorized), if an unauthenticated client is not allowed to access the schema-- `500` (Internal Server Error), for unexpected failures in the server+There are four types of validation errors: -As an example, the way authorization errors may be handled illustrates the different error conditions.-If a client is forbidden from making any GraphQL requests at all, the server may respond with-status code `403` (Forbidden) and not return any GraphQL data.-In contrast to that, a client might be allowed to access the schema, but requests some restricted fields.-Given the server can provide at least partial `data`, the response would have status code `200` (OK) and -include `errors` as part of the GraphQL response.+1. Unparseable or invalid request body, for example `NONSENSE` or `{"qeury": "{__typename}"}`+2. GraphQL Specification document validation errors (valid syntax, no loops in fragments, etc)+3. Custom document validations that can be performed before execution (e.g. graphql-depth-limit)+4. Runtime validations performed by resolvers (i.e. during the execution of the GraphQL operation). -It is RECOMMENDED to use the same error codes as the [reference implementation](https://github.com/graphql/express-graphql).+The error types 1. and 2. prevent execution of the request entirely and MUST result in+status code `400` (Bad Request). Types 3. and 4. may still allow partial execution and+MUST result in status code `200`.++If an unauthenticated client is not allowed to access the schema, the server MUST respond with+status code `401` (Unauthorized).

I should expand on the security implications I mentioned. Statuses 401 and 403 (generally) confirm the resource exists and that you're not allowed to see it, 404 does not. So some servers choose to use 404 to get bots/scripts to "stop looking" - the page doesn't seem to exist so there's no point trying to hack it. Have a read of: https://www.bennadel.com/blog/2400-handling-forbidden-restful-requests-401-vs-403-vs-404.htm

It should be up to the developer to decide which of these status codes is relevant to their API design.

spawnia

comment created time in 11 days

Pull request review commentAPIs-guru/graphql-over-http

Add clarifications regarding HTTP status codes

 The result of executing a GraphQL operation may contain partial data as well as Errors that happen during execution of the GraphQL operation typically become part of the result, as long as the server is still able to produce a well-formed response. -In case of errors that completely prevent the successful execution of the request, the server SHOULD respond-with the appropriate status code depending on the concrete error condition. For example:+In case of errors that completely prevent the successful execution of the request, the server MUST respond+with the appropriate status code depending on the concrete error condition. -- `400` (Bad Request), in case of a validation error-- `401` (Unauthorized), if an unauthenticated client is not allowed to access the schema-- `500` (Internal Server Error), for unexpected failures in the server+There are four types of validation errors: -As an example, the way authorization errors may be handled illustrates the different error conditions.-If a client is forbidden from making any GraphQL requests at all, the server may respond with-status code `403` (Forbidden) and not return any GraphQL data.-In contrast to that, a client might be allowed to access the schema, but requests some restricted fields.-Given the server can provide at least partial `data`, the response would have status code `200` (OK) and -include `errors` as part of the GraphQL response.+1. Unparseable or invalid request body, for example `NONSENSE` or `{"qeury": "{__typename}"}`+2. GraphQL Specification document validation errors (valid syntax, no loops in fragments, etc)+3. Custom document validations that can be performed before execution (e.g. graphql-depth-limit)+4. Runtime validations performed by resolvers (i.e. during the execution of the GraphQL operation). -It is RECOMMENDED to use the same error codes as the [reference implementation](https://github.com/graphql/express-graphql).+The error types 1. and 2. prevent execution of the request entirely and MUST result in+status code `400` (Bad Request). Types 3. and 4. may still allow partial execution and+MUST result in status code `200`.++If an unauthenticated client is not allowed to access the schema, the server MUST respond with+status code `401` (Unauthorized).++If the server failed unexpectedly, it MUST respond with status code `500` (Internal Server Error).++If a client is not authorized to access any of the requested fields, the server MUST respond with+status code `403` (Forbidden) and not return any `data`.

I think that the spec should be written in a way that makes compliance easy - rather than talking about it in terms of "allowed fields and disallowed fields" which is not a concept that exists in the GraphQL spec, we should talk about it in terms of successful execution. In this case what you're really saying is "should resolving the request with graphql result in the data field being null, a 4xx or 5xx status should be used".

It's my belief that you should be able to build a GraphQL server without needing to know about the internal logic of the underlying GraphQL schema - everything the server needs to know should be available as a result of calling the parse, validate and execute GraphQL functions in whatever language you're using; these functions do not have any concept of "field-level authorization".

spawnia

comment created time in 11 days

issue commentgraphile/postgraphile

Is it possible to query and filter fields of JSONB columns?

Only if you write a plugin to do so. You might find the JSONStructure example relevant: https://github.com/graphile/cookbook/tree/master/examples/json_structure

barbalex

comment created time in 11 days

issue commentgraphile/starter

yarn issue with cmd Windows

Thanks for the update, @JonParton; good luck - and I'd love to see your changes once you have it working :+1: Should you need some help do ping in discord https://discord.gg/graphile

Macfly

comment created time in 11 days

delete branch graphile/postgraphile-lambda-example

delete branch : master

delete time in 11 days

create barnchgraphile/postgraphile-lambda-example

branch : main

created branch time in 11 days

PR closed graphile/migrate

fix: watch --once --shadow should run against shadow DB

https://www.google.com/webhp؟hl=ar&sa=X&ved=0ahUKEwjcpdudl-rmAhXpsIsKHVWND6kQPAgH

+16 -11

0 comment

1 changed file

mohmmedmeshi

pr closed time in 11 days

delete branch graphile/migrate

delete branch : master

delete time in 11 days

create barnchgraphile/migrate

branch : main

created branch time in 11 days

delete branch graphile/starter

delete branch : master

delete time in 11 days

create barnchgraphile/starter

branch : main

created branch time in 11 days

delete branch graphile/worker

delete branch : master

delete time in 11 days

create barnchgraphile/worker

branch : main

created branch time in 11 days

PR closed graphile/postgraphile

Tests for Fastify plugins

This PR

  • Adds a test to check if Fastify plugins do their job when used as http server

  • Bumps Fastify to the latest version and installs fastify-helmet and fastify-compress as dev dependencies

  • The fastify-compress test is failing. It does pass when the compress middleware is used instead of the plugin

  • See #1220

+490 -95

3 comments

3 changed files

madflow

pr closed time in 11 days

PR closed graphile/postgraphile

New feature graphiql-authorization-event-origin

allows a window to update graphiql with an authorization header value to be used on every request

See postgraphiql/public/example_authorization_wrapper/index.html for a quick demo

Happy to turn it into a proper PR if there is interest.

+126 -16

1 comment

5 changed files

deinspanjer

pr closed time in 11 days

delete branch graphile/postgraphile

delete branch : master

delete time in 11 days

create barnchgraphile/postgraphile

branch : v5

created branch time in 11 days

issue closedgraphile/postgraphile

contributing docs

I wanted to try and get into the code for some potential PRs, and realized the docs are not working (at least for me on the v4 branch), maybe I'm doing something wrong?

  1. from this instruction here I ran yarn and yarn watch... nothing happened except an error message:
$ yarn watch
yarn run v1.15.2
$ /code/sandbox/postgraphile/node_modules/.bin/watch
Usage: watch <command> [...directory] [--wait=<seconds>] [--filter=<file>] [--interval=<seconds>] [--ignoreDotFiles] [--ignoreUnreadable] [--ignoreDirectoryPattern]
✨  Done in 0.19s.

this line here says to create a database called graphileengine_test. But then I ran the test and got this message:

 error: database "postgraphile_test" does not exist

good news / questions

  1. I just ignored it and was able to run tests, not sure if this is an issue or required anymore?

  2. I was able to add the database, and the tests all passed. Do we need to add both databases?

closed time in 11 days

pyramation

issue commentgraphile/postgraphile

contributing docs

I think this is resolved?

pyramation

comment created time in 11 days

Pull request review commentgraphql/graphql-js

Change type of extensions from anonymous Record to named interfaces

  const path = require('path'); const childProcess = require('child_process');+const assert = require('assert');+const fs = require('fs');+const glob = require('glob');+const semver = require('semver');  const { dependencies } = require('./package.json');  const tsVersions = Object.keys(dependencies)   .filter((pkg) => pkg.startsWith('typescript-'))   .sort((a, b) => b.localeCompare(a)); +// To allow omitting certain code from older versions of TypeScript, we have a+// "magic" comment syntax. We precede a block of code with:+//+//     /*! SEMVER_RANGE !*/+//+// replacing SEMVER_RANGE with a semver range spec, such as '>=3.2'; we+// terminate the block of code with:+//+//     /*!!*/+//+// We will only include the code between these comments if the TypeScript+// version being tested satisfies the semver range that was specified. NOTE: We+// currently do not allow nesting of these blocks.+const templates = glob.sync('./*.ts.template').map((filename) => {+  const content = fs.readFileSync(filename, 'utf8');+  const targetFilename = filename.replace(/\.template$/, '');+  assert.notEqual(filename, targetFilename);+  const writeFileSync = (version) => {+    // Captures our magic comment syntax: `/*!(CAPTURE1)!*/(CAPTURE 2)/*!!*/`+    const regex = /\/\*!([^!]+)!\*\/([\s\S]*?)\/\*!!\*\//g;+    const finalContent = content.replace(regex, (_, versionRange, payload) => {+      if (semver.satisfies(version, versionRange)) {+        return payload;+      } else {+        return '';+      }+    });+    fs.writeFileSync(targetFilename, finalContent);+  };+  return { writeFileSync };+});+ for (const version of tsVersions) {   console.log(`Testing on ${version} ...`); +  for (const template of templates) {+    template.writeFileSync(version);+  }+

I suppose the more complex ranges are enabled by having a 4.9 file and another 3.1 file; but this still seems more complex/cumbersome than just removing a block.

benjie

comment created time in 11 days

Pull request review commentgraphql/graphql-js

Change type of extensions from anonymous Record to named interfaces

  const path = require('path'); const childProcess = require('child_process');+const assert = require('assert');+const fs = require('fs');+const glob = require('glob');+const semver = require('semver');  const { dependencies } = require('./package.json');  const tsVersions = Object.keys(dependencies)   .filter((pkg) => pkg.startsWith('typescript-'))   .sort((a, b) => b.localeCompare(a)); +// To allow omitting certain code from older versions of TypeScript, we have a+// "magic" comment syntax. We precede a block of code with:+//+//     /*! SEMVER_RANGE !*/+//+// replacing SEMVER_RANGE with a semver range spec, such as '>=3.2'; we+// terminate the block of code with:+//+//     /*!!*/+//+// We will only include the code between these comments if the TypeScript+// version being tested satisfies the semver range that was specified. NOTE: We+// currently do not allow nesting of these blocks.+const templates = glob.sync('./*.ts.template').map((filename) => {+  const content = fs.readFileSync(filename, 'utf8');+  const targetFilename = filename.replace(/\.template$/, '');+  assert.notEqual(filename, targetFilename);+  const writeFileSync = (version) => {+    // Captures our magic comment syntax: `/*!(CAPTURE1)!*/(CAPTURE 2)/*!!*/`+    const regex = /\/\*!([^!]+)!\*\/([\s\S]*?)\/\*!!\*\//g;+    const finalContent = content.replace(regex, (_, versionRange, payload) => {+      if (semver.satisfies(version, versionRange)) {+        return payload;+      } else {+        return '';+      }+    });+    fs.writeFileSync(targetFilename, finalContent);+  };+  return { writeFileSync };+});+ for (const version of tsVersions) {   console.log(`Testing on ${version} ...`); +  for (const template of templates) {+    template.writeFileSync(version);+  }+

That was my first thought; but I realised that keeping these files in sync would be challenging, and it increases the amount of code in the tests without offering much in the way of value. It also doesn't allow for more complex ranges like >=3.2 <5 which may be required in future. "Turning off" a block of code seemed like the simplest solution from the point of view of writing the tests, at a slight cost of the test infrastructure being more complex.

benjie

comment created time in 11 days

push eventgraphile/graphile.github.io

Travis CI User

commit sha 18d6ff9d19ff66c78f686d1dc78ab95e2ef18dc6

Fixes from CI

view details

push time in 11 days

push eventgraphile/graphile.github.io

Benjie Gillam

commit sha 003c2665be84dd9eb1a12de706e3fd9da280794d

Cache link checks so only newly added links need testing

view details

push time in 11 days

push eventbenjie/graphql-js

Benjie Gillam

commit sha 3dee42447dac94400d1a8ee438185c9efc194a99

Lint

view details

push time in 11 days

push eventbenjie/graphql-js

Benjie Gillam

commit sha 63ebdb4d22f635e5fdb07ba0e8f57e9b41c5345c

Lint

view details

push time in 11 days

Pull request review commentgraphql/graphql-js

Change type of extensions from anonymous Record to named interfaces

  const path = require('path'); const childProcess = require('child_process');+const assert = require('assert');+const fs = require('fs');+const glob = require('glob');+const semver = require('semver');  const { dependencies } = require('./package.json');  const tsVersions = Object.keys(dependencies)   .filter((pkg) => pkg.startsWith('typescript-'))   .sort((a, b) => b.localeCompare(a)); +// To allow omitting certain code from older versions of TypeScript, we have a+// "magic" comment syntax. We precede a block of code with:+//+//     /*! SEMVER_RANGE !*/+//+// replacing SEMVER_RANGE with a semver range spec, such as '>=3.2'; we+// terminate the block of code with:+//+//     /*!!*/+//+// We will only include the code between these comments if the TypeScript+// version being tested satisfies the semver range that was specified. NOTE: We+// currently do not allow nesting of these blocks.+const templates = glob.sync('./*.ts.template').map((filename) => {+  const content = fs.readFileSync(filename, 'utf8');+  const targetFilename = filename.replace(/\.template$/, '');+  assert.notEqual(filename, targetFilename);+  const writeFileSync = (version) => {+    // Captures our magic comment syntax: `/*!(CAPTURE1)!*/(CAPTURE 2)/*!!*/`+    const regex = /\/\*!([^!]+)!\*\/([\s\S]*?)\/\*!!\*\//g;+    const finalContent = content.replace(regex, (_, versionRange, payload) => {+      if (semver.satisfies(version, versionRange)) {+        return payload;+      } else {+        return '';+      }+    });+    fs.writeFileSync(targetFilename, finalContent);+  };+  return { writeFileSync };+});+ for (const version of tsVersions) {   console.log(`Testing on ${version} ...`); +  for (const template of templates) {+    template.writeFileSync(version);+  }+

@IvanGoncharov I seek your guidance on this approach to allowing a block of code to be omitted when testing older TypeScript versions. It works; but it does mean the tests write to the filesystem, which makes me uncomfortable. It's a fairly simple implementation though, basically powered by a single regexp and the semver module.

benjie

comment created time in 11 days

Pull request review commentgraphql/graphql-js

Change type of extensions from anonymous Record to named interfaces

+import { GraphQLString, GraphQLSchema, GraphQLObjectType } from 'graphql/type';+import { ExecutionResult } from 'graphql/execution';+import { graphqlSync } from 'graphql';++interface SomeExtension {+  number: number;+  string: string;+}++const example: SomeExtension = {+  number: 42,+  string: 'Meaning of life',+};++// The following code block requires a newer version of TypeScript+/*! >=3.2 !*/

This "magic comment" syntax is documented in test.js

benjie

comment created time in 11 days

Pull request review commentgraphql/graphql-js

Change type of extensions from anonymous Record to named interfaces

-import { GraphQLString, GraphQLSchema, GraphQLObjectType } from 'graphql/type';

This entire file was renamed to integrationTests.ts.template

benjie

comment created time in 11 days

push eventbenjie/graphql-js

Benjie Gillam

commit sha 9c4e8601fab57fd7a6adf806650727316ff2f24e

Allow testing certain code blocks on only specific TypeScript versions

view details

push time in 11 days

push eventgraphile/graphile.github.io

Travis CI User

commit sha 4e2bd13de9deefa60b6c3f7c5b746d2860cb1494

Fixes from CI

view details

push time in 11 days

pull request commentgraphql/graphql-js

Add parentType to path to avoid path ambiguity

@IvanGoncharov Just a ping in case the "request review" above didn't hit your radar.

benjie

comment created time in 11 days

push eventgraphile/graphile.github.io

Jan Lohage

commit sha a44b1be8763e0b9500a0e55bd46219330364c3dc

Update smart-comments.md Change `@omit insert` to `@omit create`

view details

Benjie Gillam

commit sha 59ed91114ca9b1c9ea243d60af3f8bc4a95d65dc

Merge pull request #230 from j2L4e/patch-1

view details

push time in 11 days

PR merged graphile/graphile.github.io

Update smart-comments.md

Change @omit insert to @omit create

+1 -1

0 comment

1 changed file

j2L4e

pr closed time in 11 days

push eventgraphile/starter

lukeramsden

commit sha 74a37eedd8f41fe03e802e6298f37ae99b8721c3

Converted SharedLayout->AuthRestrict to flag enum

view details

Benjie Gillam

commit sha 58699dd1b759a3dd8e6f50cdc0622979f037e897

Merge pull request #174 from lukeramsden/patch-1

view details

push time in 11 days

PR merged graphile/starter

Converted SharedLayout->AuthRestrict to flag enum to allow for multiple forbid conditions

Also added IS_ADMIN and NOT_ADMIN flags. This is better because it allows for multiple forbid conditions, as well as easy extension. The IS_ADMIN/NOT_ADMIN check is kinda ugly but that's how it's auto-formatted so I've kept it like that for this PR.

+13 -5

1 comment

1 changed file

lukeramsden

pr closed time in 11 days

pull request commentgraphile/federation

try to use primary key as additional @key directive

@graphile/federation-team may merge it at will; I'm not involved in any APIs using Federation so don't have sufficient context to maintain this project.

phryneas

comment created time in 11 days

pull request commentgraphile/postgraphile-lambda-example

Simple deployment using web server less plugins.

Hey @RoryKelly; I'd be happy to link to https://github.com/puddlealley/postgraphile-lambda-example from the README; would you be able to modify your README to detail how your solution works? (Feel free to completely delete the existing text from your fork.)

RoryKelly

comment created time in 11 days

push eventgraphile/graphile.github.io

hsanoyan

commit sha b1ff3af338d7faf11c823f32ab55a28406d63827

Add note for NOTIFY postgraphile_watch

view details

Benjie Gillam

commit sha 2452992f2802e8e0b980d82fc78620caeeb6091d

Edit watchPg description

view details

Benjie Gillam

commit sha c86987ad492a29d7f097bfda121202ed8337dd1c

Merge pull request #229 from hos/develop

view details

push time in 12 days

push eventhos/graphile.github.io

Benjie Gillam

commit sha 2452992f2802e8e0b980d82fc78620caeeb6091d

Edit watchPg description

view details

push time in 12 days

issue closedgraphile/graphile-engine

[graphql-parse-resolve-info] Missing documentation for ParseOptions passed to parseResolveInfo

The README.md file is missing information regarding the ParseOptions argument.

closed time in 12 days

glen-84
more