From 5eb862329fc5c446826e60583f7cd920fd1409ce Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Mon, 21 Nov 2022 14:25:45 +1100 Subject: [PATCH 1/4] dont throw if unknown pull request --- scripts/changelog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/changelog.js b/scripts/changelog.js index a15b545bcfb..764fe59b8e6 100644 --- a/scripts/changelog.js +++ b/scripts/changelog.js @@ -85,7 +85,7 @@ async function fetchData(tag) { const changes = {}; for (const commit of revs) { let { user, pull } = await getInfo({ repo: 'keystonejs/keystone', commit }); - pull = pull || gitCommitDescription(commit).match(/#([0-9]+)/)[1]; + pull = pull || gitCommitDescription(commit).match(/#([0-9]+)/)?.[1] console.error(`commit ${commit}, user ${user}, pull #${pull}`); const change = { commit, user, pull }; From 442434d69cf0e510a5f7cdae1be6fb8f7bb25e07 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Tue, 22 Nov 2022 18:21:55 +1100 Subject: [PATCH 2/4] reduce getDbAPIFactory Typescript complexity --- packages/core/src/lib/context/itemAPI.ts | 30 +++++++++++++----------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/packages/core/src/lib/context/itemAPI.ts b/packages/core/src/lib/context/itemAPI.ts index 64eb579af3a..fd1a8fb8968 100644 --- a/packages/core/src/lib/context/itemAPI.ts +++ b/packages/core/src/lib/context/itemAPI.ts @@ -9,12 +9,6 @@ import { import { executeGraphQLFieldToRootVal } from './executeGraphQLFieldToRootVal'; import { executeGraphQLFieldWithSelection } from './executeGraphQLFieldWithSelection'; -// this is generally incorrect because types are open in TS but is correct in the specific usage here. -// (i mean it's not really any more incorrect than TS is generally is but let's ignore that) -const objectEntriesButUsingKeyof: >( - obj: T -) => [keyof T, T[keyof T]][] = Object.entries as any; - export function getDbAPIFactory( gqlNames: GqlNames, schema: GraphQLSchema @@ -32,7 +26,8 @@ export function getDbAPIFactory( } return executeGraphQLFieldToRootVal(field); }; - const api = { + + const fcache = { findOne: f('query', gqlNames.itemQueryName), findMany: f('query', gqlNames.listQueryName), count: f('query', gqlNames.listQueryCountName), @@ -43,13 +38,20 @@ export function getDbAPIFactory( deleteOne: f('mutation', gqlNames.deleteMutationName), deleteMany: f('mutation', gqlNames.deleteManyMutationName), }; - return (context: KeystoneContext) => - Object.fromEntries( - objectEntriesButUsingKeyof(api).map(([key, impl]) => [ - key, - (args: Record) => impl(args, context), - ]) - ) as Record; + + return (context: KeystoneContext) => { + return { + findOne: (args: Record) => fcache.findOne(args, context), + findMany: (args: Record) => fcache.findMany(args, context), + count: (args: Record) => fcache.count(args, context), + createOne: (args: Record) => fcache.createOne(args, context), + createMany: (args: Record) => fcache.createMany(args, context), + updateOne: (args: Record) => fcache.updateOne(args, context), + updateMany: (args: Record) => fcache.updateMany(args, context), + deleteOne: (args: Record) => fcache.deleteOne(args, context), + deleteMany: (args: Record) => fcache.deleteMany(args, context), + }; + }; } export function itemAPIForList( From ff7b8168f0248ff93cb82186f3f9c813c8a3bd6c Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Fri, 3 Feb 2023 14:40:48 +1100 Subject: [PATCH 3/4] remove wrong comment --- packages/core/src/types/config/fields.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/core/src/types/config/fields.ts b/packages/core/src/types/config/fields.ts index e7a6b64ef42..d2ca831139a 100644 --- a/packages/core/src/types/config/fields.ts +++ b/packages/core/src/types/config/fields.ts @@ -52,7 +52,6 @@ export type CommonFieldConfig = { update?: boolean; }; }; - // Disabled by default... isFilterable?: boolean | ((args: FilterOrderArgs) => MaybePromise); isOrderable?: boolean | ((args: FilterOrderArgs) => MaybePromise); }; From 87181c2448e7b0100b4fbafbc49bbd5e3842935b Mon Sep 17 00:00:00 2001 From: Daniel Cousens <413395+dcousens@users.noreply.github.com> Date: Mon, 13 Feb 2023 17:39:00 +1100 Subject: [PATCH 4/4] yarn format --- scripts/changelog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/changelog.js b/scripts/changelog.js index 764fe59b8e6..9de314a91ed 100644 --- a/scripts/changelog.js +++ b/scripts/changelog.js @@ -85,7 +85,7 @@ async function fetchData(tag) { const changes = {}; for (const commit of revs) { let { user, pull } = await getInfo({ repo: 'keystonejs/keystone', commit }); - pull = pull || gitCommitDescription(commit).match(/#([0-9]+)/)?.[1] + pull = pull || gitCommitDescription(commit).match(/#([0-9]+)/)?.[1]; console.error(`commit ${commit}, user ${user}, pull #${pull}`); const change = { commit, user, pull };