From f86a403630702f3f26f348ad26af02b0a06a7c98 Mon Sep 17 00:00:00 2001 From: abhiaiyer91 Date: Wed, 7 Jul 2021 13:47:39 -0700 Subject: [PATCH 1/5] Deprecate createTypes in sourceNodes --- packages/gatsby/src/redux/actions/restricted.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/gatsby/src/redux/actions/restricted.ts b/packages/gatsby/src/redux/actions/restricted.ts index d73742323c73a..fb6042e407ab4 100644 --- a/packages/gatsby/src/redux/actions/restricted.ts +++ b/packages/gatsby/src/redux/actions/restricted.ts @@ -523,8 +523,8 @@ export const availableActionsByAPI = mapAvailableActionsToAPIs({ [ALLOWED_IN]: [`sourceNodes`, `createSchemaCustomization`], }, createTypes: { - [ALLOWED_IN]: [`sourceNodes`, `createSchemaCustomization`], - [DEPRECATED_IN]: [`onPreInit`, `onPreBootstrap`], + [ALLOWED_IN]: [`createSchemaCustomization`], + [DEPRECATED_IN]: [`onPreInit`, `onPreBootstrap`, `sourceNodes`], }, createResolverContext: { [ALLOWED_IN]: [`createSchemaCustomization`], From 6c373df1c7a697e09a7814981818c1ce4d052338 Mon Sep 17 00:00:00 2001 From: abhiaiyer91 Date: Mon, 12 Jul 2021 09:44:17 -0700 Subject: [PATCH 2/5] Update the restriction list for other schema-related actions --- packages/gatsby/src/redux/actions/restricted.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/gatsby/src/redux/actions/restricted.ts b/packages/gatsby/src/redux/actions/restricted.ts index fb6042e407ab4..3c6915e80d46b 100644 --- a/packages/gatsby/src/redux/actions/restricted.ts +++ b/packages/gatsby/src/redux/actions/restricted.ts @@ -520,7 +520,8 @@ const mapAvailableActionsToAPIs = ( export const availableActionsByAPI = mapAvailableActionsToAPIs({ createFieldExtension: { - [ALLOWED_IN]: [`sourceNodes`, `createSchemaCustomization`], + [ALLOWED_IN]: [`createSchemaCustomization`], + [DEPRECATED_IN]: [`sourceNodes`], }, createTypes: { [ALLOWED_IN]: [`createSchemaCustomization`], @@ -530,8 +531,8 @@ export const availableActionsByAPI = mapAvailableActionsToAPIs({ [ALLOWED_IN]: [`createSchemaCustomization`], }, addThirdPartySchema: { - [ALLOWED_IN]: [`sourceNodes`, `createSchemaCustomization`], - [DEPRECATED_IN]: [`onPreInit`, `onPreBootstrap`], + [ALLOWED_IN]: [`createSchemaCustomization`], + [DEPRECATED_IN]: [`onPreInit`, `onPreBootstrap`, `sourceNodes`], }, printTypeDefinitions: { [ALLOWED_IN]: [`createSchemaCustomization`], From 6615a2dcc25c22c3c30cb2822a7cc7a2d2760de4 Mon Sep 17 00:00:00 2001 From: abhiaiyer91 Date: Mon, 12 Jul 2021 10:25:08 -0700 Subject: [PATCH 3/5] Update snapshots --- .../npm/__snapshots__/package.test.js.snap | 20 +++++++++---------- .../src/redux/actions/__tests__/restricted.js | 9 +++++++-- .../src/utils/worker/__tests__/share-state.ts | 17 +--------------- 3 files changed, 18 insertions(+), 28 deletions(-) diff --git a/packages/gatsby-recipes/src/providers/npm/__snapshots__/package.test.js.snap b/packages/gatsby-recipes/src/providers/npm/__snapshots__/package.test.js.snap index 1386303baa81e..cf64c4a9a566a 100644 --- a/packages/gatsby-recipes/src/providers/npm/__snapshots__/package.test.js.snap +++ b/packages/gatsby-recipes/src/providers/npm/__snapshots__/package.test.js.snap @@ -18,16 +18,6 @@ Object { } `; -exports[`npm package resource e2e npm package resource test: NPMPackage destroy 1`] = ` -Object { - "_message": "Installed NPM package is-sorted@1.0.2", - "description": "A small module to check if an Array is sorted", - "id": "is-sorted", - "name": "is-sorted", - "version": "1.0.2", -} -`; - exports[`npm package resource e2e npm package resource test: NPMPackage update 1`] = ` Object { "_message": "Installed NPM package is-sorted@1.0.2", @@ -66,6 +56,16 @@ Object { } `; +exports[`npm package resource installs 2 resources, one prod & one dev: NPMPackage destroy 1`] = ` +Object { + "_message": "Installed NPM package is-sorted@1.0.2", + "description": "A small module to check if an Array is sorted", + "id": "is-sorted", + "name": "is-sorted", + "version": "1.0.2", +} +`; + exports[`package manager client commands generates the correct commands for npm 1`] = ` Array [ "install", diff --git a/packages/gatsby/src/redux/actions/__tests__/restricted.js b/packages/gatsby/src/redux/actions/__tests__/restricted.js index b4be6ebb6dc19..fff7ccc78c205 100644 --- a/packages/gatsby/src/redux/actions/__tests__/restricted.js +++ b/packages/gatsby/src/redux/actions/__tests__/restricted.js @@ -14,7 +14,7 @@ const dispatchWithThunk = actionOrThunk => describe(`Restricted actions`, () => { it(`handles actions allowed in API`, () => { const action = dispatchWithThunk( - availableActionsByAPI.sourceNodes.createTypes() + availableActionsByAPI.createSchemaCustomization.createTypes() ) expect(action).toEqual({ type: `CREATE_TYPES` }) expect(report.warn).not.toHaveBeenCalled() @@ -22,12 +22,17 @@ describe(`Restricted actions`, () => { }) it(`handles actions deprecated in API`, () => { - const action = dispatchWithThunk( + let action = dispatchWithThunk( availableActionsByAPI.onPreBootstrap.createTypes() ) expect(action).toEqual({ type: `CREATE_TYPES` }) expect(report.warn).toHaveBeenCalled() expect(report.error).not.toHaveBeenCalled() + + action = dispatchWithThunk(availableActionsByAPI.sourceNodes.createTypes()) + expect(action).toEqual({ type: `CREATE_TYPES` }) + expect(report.warn).toHaveBeenCalled() + expect(report.error).not.toHaveBeenCalled() }) it(`handles actions forbidden in API`, () => { diff --git a/packages/gatsby/src/utils/worker/__tests__/share-state.ts b/packages/gatsby/src/utils/worker/__tests__/share-state.ts index 42dc28c4bbe82..9f99cabf85321 100644 --- a/packages/gatsby/src/utils/worker/__tests__/share-state.ts +++ b/packages/gatsby/src/utils/worker/__tests__/share-state.ts @@ -262,21 +262,6 @@ describe(`worker (share-state)`, () => { const inf = await worker.single.getInferenceMetadata(`Test`) - expect(inf).toMatchInlineSnapshot(` - Object { - "dirty": true, - "fieldMap": Object { - "foo": Object { - "string": Object { - "example": "bar", - "first": "1", - "total": 1, - }, - }, - }, - "ignoredFields": Object {}, - "total": 1, - } - `) + expect(inf).toMatchInlineSnapshot(`null`) }) }) From e6beec81367f1f332544b6c90399463713b187d8 Mon Sep 17 00:00:00 2001 From: Lennart Date: Tue, 13 Jul 2021 08:50:44 +0200 Subject: [PATCH 4/5] Restore package.test.js.snap --- .../npm/__snapshots__/package.test.js.snap | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/gatsby-recipes/src/providers/npm/__snapshots__/package.test.js.snap b/packages/gatsby-recipes/src/providers/npm/__snapshots__/package.test.js.snap index cf64c4a9a566a..1386303baa81e 100644 --- a/packages/gatsby-recipes/src/providers/npm/__snapshots__/package.test.js.snap +++ b/packages/gatsby-recipes/src/providers/npm/__snapshots__/package.test.js.snap @@ -18,6 +18,16 @@ Object { } `; +exports[`npm package resource e2e npm package resource test: NPMPackage destroy 1`] = ` +Object { + "_message": "Installed NPM package is-sorted@1.0.2", + "description": "A small module to check if an Array is sorted", + "id": "is-sorted", + "name": "is-sorted", + "version": "1.0.2", +} +`; + exports[`npm package resource e2e npm package resource test: NPMPackage update 1`] = ` Object { "_message": "Installed NPM package is-sorted@1.0.2", @@ -56,16 +66,6 @@ Object { } `; -exports[`npm package resource installs 2 resources, one prod & one dev: NPMPackage destroy 1`] = ` -Object { - "_message": "Installed NPM package is-sorted@1.0.2", - "description": "A small module to check if an Array is sorted", - "id": "is-sorted", - "name": "is-sorted", - "version": "1.0.2", -} -`; - exports[`package manager client commands generates the correct commands for npm 1`] = ` Array [ "install", From 388cb7165aaba9df35275e2f2881bfc987377c26 Mon Sep 17 00:00:00 2001 From: Lennart Date: Tue, 13 Jul 2021 08:50:54 +0200 Subject: [PATCH 5/5] Restore share-state.ts --- .../src/utils/worker/__tests__/share-state.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/gatsby/src/utils/worker/__tests__/share-state.ts b/packages/gatsby/src/utils/worker/__tests__/share-state.ts index 9f99cabf85321..42dc28c4bbe82 100644 --- a/packages/gatsby/src/utils/worker/__tests__/share-state.ts +++ b/packages/gatsby/src/utils/worker/__tests__/share-state.ts @@ -262,6 +262,21 @@ describe(`worker (share-state)`, () => { const inf = await worker.single.getInferenceMetadata(`Test`) - expect(inf).toMatchInlineSnapshot(`null`) + expect(inf).toMatchInlineSnapshot(` + Object { + "dirty": true, + "fieldMap": Object { + "foo": Object { + "string": Object { + "example": "bar", + "first": "1", + "total": 1, + }, + }, + }, + "ignoredFields": Object {}, + "total": 1, + } + `) }) })