UNPKG

946 BJavaScriptView Raw
1"use strict";
2
3const {
4 supportedExtensions
5} = require(`./supported-extensions`);
6
7module.exports = ({
8 createResolvers,
9 reporter
10}, pluginOptions = {}) => {
11 const {
12 checkSupportedExtensions = true
13 } = pluginOptions;
14 const resolvers = {
15 File: {
16 childImageSharp: {
17 resolve: (parent, args, context, info) => {
18 // TODO: In future when components from GraphQL are possible make sure that we can support both supported & unsupported image formats
19 if (!supportedExtensions[parent.extension] && checkSupportedExtensions) {
20 reporter.warn(`You can't use childImageSharp together with ${parent.name}.${parent.extension} — use publicURL instead. The childImageSharp portion of the query in this file will return null:\n${context.componentPath}`);
21 }
22
23 return info.originalResolver(parent, args, context, info);
24 }
25 }
26 }
27 };
28 createResolvers(resolvers);
29};
\No newline at end of file