Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing onError handler for invocation 'building-schema', error was 'Error: Schema must contain uniquely named types but contains multiple types named "File".'. Stacktrace was 'Error: Schema must contain uniquely named types but contains multiple types named "File". #6

Open
3 tasks done
blocus opened this issue Oct 10, 2022 · 1 comment

Comments

@blocus
Copy link

blocus commented Oct 10, 2022

Preflight Checklist

Describe the Bug

gatsby throws an error when reloading a page file.

info changed file at /home/user/project/src/pages/index.js

 ERROR 

Missing onError handler for invocation 'building-schema', error was 'Error: Schema must contain uniquely named types but contains multiple types named
"File".'. Stacktrace was 'Error: Schema must contain uniquely named types but contains multiple types named "File".
    at new GraphQLSchema (/home/user/project/node_modules/graphql/type/schema.js:194:15)
    at SchemaComposer.buildSchema (/home/user/project/node_modules/graphql-compose/src/SchemaComposer.ts:242:12)
    at buildSchema (/home/user/project/node_modules/gatsby/src/schema/schema.js:84:33)
    at build (/home/user/project/node_modules/gatsby/src/schema/index.js:111:18)
    at buildSchema (/home/user/project/node_modules/gatsby/src/services/build-schema.ts:19:3)'

When I start the development server there are no issue but when I reload any page existing in ./src/pages/ I got this error.

To Reproduce

1 - Init a fresh gatsby project (Typescript or javascript) I tested both
2 - In package.json

{
  ...
  "keywords": [
    "gatsby"
  ],
  "scripts": {
    "develop": "gatsby develop",
    "start": "gatsby develop",
    "build": "gatsby build",
    "serve": "gatsby serve -p 5000",
    "clean": "gatsby clean",
    "lighthouse": "lhci autorun"
  },
  "dependencies": {
    "@directus/gatsby-source-directus": "^9.14.1",
    "@fortawesome/fontawesome-free": "^6.2.0",
    "dotenv": "^16.0.3",
    "gatsby": "^4.24.4",
    "gatsby-plugin-google-gtag": "^4.24.0",
    "gatsby-plugin-image": "^2.24.0",
    "gatsby-plugin-manifest": "^4.24.0",
    "gatsby-plugin-sass": "^5.24.0",
    "gatsby-plugin-sharp": "^4.24.0",
    "gatsby-plugin-sitemap": "^5.24.0",
    "gatsby-source-filesystem": "^4.24.0",
    "gatsby-transformer-sharp": "^4.24.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-helmet": "^6.1.0",
    "sass": "^1.55.0"
  },
  "devDependencies": {
    "@lhci/cli": "^0.8.2"
  }
}

3 - In gatsby-config

require('dotenv').config()

module.exports = {
  siteMetadata: {
    ...
  },
  plugins: [
    'gatsby-plugin-image',
    'gatsby-plugin-sitemap',
    {
      resolve: `gatsby-plugin-google-gtag`,
      options: {
        trackingIds: [process.env.GTAG_MEASUREMENT_ID],
        pluginConfig: {
          head: true,
        },
      },
    },
    {
      resolve: 'gatsby-plugin-manifest',
      options: {
        icon: 'src/images/icon.png',
      },
    },
    'gatsby-plugin-sharp',
    'gatsby-transformer-sharp',
    `gatsby-plugin-sass`,
    {
      resolve: 'gatsby-source-filesystem',
      options: { name: 'images', path: './src/images/' },
      __key: 'images',
    },
    {
      resolve: 'gatsby-source-filesystem',
      options: { name: 'pages', path: './src/pages/' },
      __key: 'pages',
    },
    {
      resolve: 'gatsby-source-filesystem',
      options: { name: 'static', path: './src/static/' },
      __key: 'static',
    },
    {
      resolve: '@directus/gatsby-source-directus',
      options: {
        url: process.env.DIRECTUS_API_URL,
        auth: { token: process.env.DIRECTUS_API_KEY },
      },
    },
  ],
}

4 - Start the development server (it will work)
5 - Make a minor change in src/pages/index.js and save
6 - You will get the error

What version of Directus are you using?

9.18.1

What version of Node.js are you using?

v16.17.1

What version of Node.js are you using with gatsby?

v16.16.0

What database are you using?

MySql

What operating system are you using?

Linux 5.10.76-linuxkit

How are you deploying Directus?

On a VPS with pm2 and nginx for reverse proxy

@rijkvanzanten
Copy link
Member

Linear: ENG-60

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants