gatsby: [gatsby-source-filesystem] pluging breaks building schema step

Description

After adding gatsby-source-filesystem:

{
  resolve: `gatsby-source-filesystem`,
  options: {
    name: `images`,
    path: `${__dirname}/src/images/`,
  },
},

to the gatsby-config.js Gatsby develop & build break. Error:

  Error: File.publicURL provided incorrect OutputType: 'String'

image

Steps to reproduce

I can’t reproduce it on a clean repository. It happens only in a workspace which is a part of a bigger monorepo. I would like to debug what causes the problem.

Expected result

Adding gatsby-source-filesystem shouldn’t break building schema step

Actual result

building schema step ends with an error:

success open and validate gatsby-configs - 0.035s
success load plugins - 0.528s
success onPreInit - 0.004s
info One or more of your plugins have changed since the last time you ran Gatsby. As
a precaution, we're deleting your site's cache to ensure there's no stale data.
success initialize cache - 0.027s
success copy gatsby files - 0.163s
success onPreBootstrap - 0.079s
success createSchemaCustomization - 0.003s
success source and transform nodes - 0.101s
⠋ building schema

 ERROR

UNHANDLED REJECTION File.publicURL provided incorrect OutputType: 'String'



  Error: File.publicURL provided incorrect OutputType: 'String'

  - TypeMapper.js:294 TypeMapper.convertOutputFieldConfig
    [website]/[graphql-compose]/lib/TypeMapper.js:294:15

  - configAsThunk.js:19 resolveOutputConfigAsThunk
    [website]/[graphql-compose]/lib/utils/configAsThunk.js:19:41

  - ObjectTypeComposer.js:300 ObjectTypeComposer.getFieldConfig
    [website]/[graphql-compose]/lib/ObjectTypeComposer.js:300:58

  - toInputObjectType.js:44
    [website]/[graphql-compose]/lib/utils/toInputObjectType.js:44:19

  - Array.forEach

  - toInputObjectType.js:38 toInputObjectType
    [website]/[graphql-compose]/lib/utils/toInputObjectType.js:38:14

  - ObjectTypeComposer.js:600 ObjectTypeComposer.getInputTypeComposer
    [website]/[graphql-compose]/lib/ObjectTypeComposer.js:600:84

  - sort.js:54 getSortInput
    [website]/[gatsby]/dist/schema/types/sort.js:54:42

  - schema.js:1104 addTypeToRootQuery
    [website]/[gatsby]/dist/schema/schema.js:1104:23

  - schema.js:270 processTypeComposer
    [website]/[gatsby]/dist/schema/schema.js:270:13

  - async Promise.all

  - schema.js:211 async updateSchemaComposer
    [website]/[gatsby]/dist/schema/schema.js:211:3

  - schema.js:95 async buildSchema
    [website]/[gatsby]/dist/schema/schema.js:95:3

  - index.js:136 async Object.build
    [website]/[gatsby]/dist/schema/index.js:136:18

  - index.js:415 async module.exports
    [website]/[gatsby]/dist/bootstrap/index.js:415:3

  - develop.js:407 async module.exports
    [website]/[gatsby]/dist/commands/develop.js:407:7

⠋ building schema

Environment

Languages: Python: 2.7.17 - /usr/local/bin/python Browsers: Chrome: 79.0.3945.117 Safari: 13.0.4 npmPackages: gatsby: ^2.18.12 => 2.18.17 npmGlobalPackages: gatsby: 2.18.17

gatsby-config.js

/**
 * Configure your Gatsby site with this file.
 *
 * See: https://www.gatsbyjs.org/docs/gatsby-config/
 */

module.exports = {
  /* Your site config here */
  plugins: [
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `images`,
        path: `${__dirname}/src/images/`,
      },
    },
    'gatsby-plugin-typescript',
    'gatsby-plugin-typescript-checker',
    {
      resolve: 'gatsby-plugin-eslint',
      options: {
        test: /\.js$|\.jsx$|\.ts$|\.tsx$/,
        exclude: /(node_modules|.cache|public)/,
        stages: ['develop'],
        options: {
          emitWarning: true,
          failOnError: false,
        },
      },
    },
    {
      resolve: 'gatsby-plugin-react-svg',
      options: {
        rule: {
          include: /assets\/.*\.svg/,
        },
      },
    },
    {
      resolve: `gatsby-plugin-intl`,
      options: {
        // language JSON resource path
        path: `${__dirname}/src/intl`,
        // supported language
        languages: [`en`, `de`],
        // language file path
        defaultLanguage: `en`,
        // option to redirect to `/en` when connecting `/`
        redirect: false,
      },
    },
  ],
}

gatsby-node.js

// eslint-disable-next-line @typescript-eslint/no-var-requires
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin')

exports.onCreateWebpackConfig = ({ actions }) => {
  actions.setWebpackConfig({
    resolve: {
      plugins: [new TsconfigPathsPlugin()],
    },
  })
}

gatsby-browser.js

import './src/styles'

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 15 (3 by maintainers)

Most upvoted comments

I have the same problem. My setup is: yarn link gatsby-theme-xyz, yarn install and gatsby build then fails with this error. Could this be connected to the yarn link? Problem with themes?

EDIT: I just published my theme to npm and the problem disappeared. It has to be something with the yarn link or workspaces

@orifmilod Only by a workaround - keeping the project out of workspaces. Do you use yarn workspaces as well?