UNPKG

gatsby-source-payload-cms

Version:

Source data from Payload CMS

23 lines (22 loc) 1.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.onPluginInit = void 0; const constants_1 = require("./constants"); /** * Use the onPluginInit API to set up things that should be run before the plugin is initialized. * You can use this e.g. for the reporter.setErrorMap API. Using this API is optional, but highly recommended. * By providing your own errors you can make it clearer to your users where the error is coming from and you can control what to show. * Using the ERROR_CODES enum you can reference the IDs without knowing them by hard. * @see https://www.gatsbyjs.com/docs/reference/config-files/gatsby-node/#onPluginInit * @see https://www.gatsbyjs.com/docs/reference/config-files/node-api-helpers/#reporter */ const onPluginInit = ({ reporter }) => { reporter.setErrorMap({ [constants_1.ERROR_CODES.GraphQLSourcing]: { text: (context) => `${context.sourceMessage}: ${context.graphqlError}`, level: `ERROR`, category: `THIRD_PARTY`, }, }); }; exports.onPluginInit = onPluginInit;