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

Created on 20 Jan 2020  Â·  12Comments  Â·  Source: gatsbyjs/gatsby

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

```javascript
import './src/styles'
````

stale? needs reproduction

Most helpful comment

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...

All 12 comments

My best guess would be that you have two versions of the graphql package in your repo somehow. But I may be wrong.

I am happy to help to debug this but it is rather hard without at least some reproduction.

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

Hey again!

It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.
Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks again for being part of the Gatsby community! 💪💜

you can remove the node_modules dir, and re run npm install/ yarn install. and the problem will be solved

Have you installed?: npm install --save gatsby-source-filesystem

I've just recently encountered this issue and it turned out that I forgot to install the plugin first.

@RichardStark tried multiple times, did not help
@tomwanderer yes, gatsby-source-filesystem is installed in a project

@jepek Have you fixed this issue? I am facing the same problem at the moment.

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

I am also facing the same issue. No luck with the above solutions.

@jepek No, I use npm. I had problems with conflicts with AWS-appsync. which was then fixed by just uninstalling the package and reinstalling it, maybe there was a bug in the older version, not sure tho.

I delete the node_modules directory of this project, and run npm install.
It works for me.

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...

Was this page helpful?
0 / 5 - 0 ratings