1 | "use strict";
|
2 |
|
3 | const {
|
4 | supportedExtensions
|
5 | } = require(`./supported-extensions`);
|
6 |
|
7 | module.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 |
|
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 |