Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/gatsby/src/redux/actions/__tests__/restricted.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,25 @@ 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()
expect(report.error).not.toHaveBeenCalled()
})

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`, () => {
Expand Down
11 changes: 6 additions & 5 deletions packages/gatsby/src/redux/actions/restricted.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,18 +522,19 @@ const mapAvailableActionsToAPIs = (

export const availableActionsByAPI = mapAvailableActionsToAPIs({
createFieldExtension: {
[ALLOWED_IN]: [`sourceNodes`, `createSchemaCustomization`],
[ALLOWED_IN]: [`createSchemaCustomization`],
[DEPRECATED_IN]: [`sourceNodes`],
},
createTypes: {
[ALLOWED_IN]: [`sourceNodes`, `createSchemaCustomization`],
[DEPRECATED_IN]: [`onPreInit`, `onPreBootstrap`],
[ALLOWED_IN]: [`createSchemaCustomization`],
[DEPRECATED_IN]: [`onPreInit`, `onPreBootstrap`, `sourceNodes`],
},
createResolverContext: {
[ALLOWED_IN]: [`createSchemaCustomization`],
},
addThirdPartySchema: {
[ALLOWED_IN]: [`sourceNodes`, `createSchemaCustomization`],
[DEPRECATED_IN]: [`onPreInit`, `onPreBootstrap`],
[ALLOWED_IN]: [`createSchemaCustomization`],
[DEPRECATED_IN]: [`onPreInit`, `onPreBootstrap`, `sourceNodes`],
},
printTypeDefinitions: {
[ALLOWED_IN]: [`createSchemaCustomization`],
Expand Down