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".
blocus opened this issue · comments
Preflight Checklist
- I have completed all Troubleshooting Steps.
- I'm on the latest version of Directus.
- There's no other issue that already describes my problem.
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
Linear: ENG-60