UNPKG

gatsby-source-wordpress

Version:

Source data from WordPress in an efficient and scalable way.

80 lines (77 loc) 2.47 kB
"use strict"; exports.__esModule = true; exports.default = void 0; var _core = require("@rematch/core"); var _helpers = require("../steps/create-schema-customization/helpers"); /* eslint-disable @typescript-eslint/no-explicit-any */ const remoteSchema = (0, _core.createModel)()({ state: { wpUrl: null, nodeQueries: {}, nonNodeQuery: null, introspectionData: null, schemaWasChanged: null, typeMap: null, nodeListFilter: field => field.name === `nodes`, ingestibles: { nodeListRootFields: null, nodeInterfaceTypes: null, nonNodeRootFields: [] }, allowRefreshSchemaUpdate: false, fetchedTypes: new Map(), fieldBlacklist: [`isWpGatsby`, `edges`, // these aren't useful without authentication `revisions`, `isJwtAuthSecretRevoked`, `isRestricted`, `jwtAuthExpiration`, `jwtAuthToken`, `jwtRefreshToken`, `jwtUserSecret`, `editLock`, `revisionOf`, `preview`, `isPreview`, `previewRevisionDatabaseId`, `previewRevisionId`, `editingLockedBy`, `cursor`], // @todo make this a plugin option fieldAliases: { parent: `wpParent`, children: `wpChildren`, internal: `wpInternal`, plugin: `wpPlugin`, actionOptions: `wpActionOptions`, fields: `wpFields` } }, reducers: { toggleAllowRefreshSchemaUpdate(state) { state.allowRefreshSchemaUpdate = !state.allowRefreshSchemaUpdate; return state; }, setSchemaWasChanged(state, payload) { state.schemaWasChanged = !!payload; return state; }, addFieldsToBlackList(state, payload) { state.fieldBlacklist = [...state.fieldBlacklist, ...payload]; return state; }, setState(state, payload) { state = { ...state, ...payload }; return state; }, addFetchedType(state, type) { const key = (0, _helpers.findNamedTypeName)(type); if (!key) { return state; } type = state.typeMap.get(key); // union types with no member types will cause schema customization errors // @todo move this to a better place. This should be excluded before it gets to this point. if (type && type.kind === `UNION` && type.possibleTypes.length === 0) { return state; } state.fetchedTypes.set(key, type); return state; } }, effects: () => { return {}; } }); var _default = remoteSchema; exports.default = _default; //# sourceMappingURL=remoteSchema.js.map