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

Error: Schema must contain uniquely named types but contains multiple types named "RemarkHeadingLevels". #299

Open
santoshdahal2016 opened this issue Oct 29, 2019 · 15 comments
Labels
bug Something isn't working

Comments

@santoshdahal2016
Copy link

I encountered this error during running newly fetch projects.
OS: Ubuntu 18.04

@carloscabral
Copy link
Contributor

Same here.

@weaversam8
Copy link
Contributor

I also encountered this issue on running gridsome develop on the gridsome.org repository.

@as3k
Copy link

as3k commented Dec 16, 2019

I had the same problem earlier today. I removed node_modules and then installed with yarn instead of npm. After installing with yarn everything worked fine.

@mtlynch mtlynch added the bug Something isn't working label Jun 7, 2020
@tiptronic
Copy link

nope - same thing here... swapping npw with yarn didn't help

@stereokai
Copy link

I'm stuck with this too

@TerabyteTiger
Copy link
Member

I haven't run into this on Windows 10 using PowerShell or CMD - Can someone provide additional details so it's easier to look into this?

  • Which Gridsome CLI Version?
  • Post the error message with context for source of the error
  • Is this happening on projects other than Gridsome.org?

Thanks!

@stereokai
Copy link

@TerabyteTiger I am getting this error on Mac. I also tagged you in a duplicate similar issue. Thank you for looking into this!

Description

Gridsome v0.7.19

Initializing plugins...
Load sources - 0s
Error: Schema must contain uniquely named types but contains multiple types named "Mutation".
    at typeMapReducer (project/node_modules/.pnpm/[email protected]/node_modules/graphql/type/schema.js:262:13)
    at Array.reduce (<anonymous>)
    at new GraphQLSchema (project/node_modules/.pnpm/[email protected]/node_modules/graphql/type/schema.js:145:28)
    at SchemaComposer.buildSchema (project/node_modules/.pnpm/[email protected][email protected]/node_modules/graphql-compose/lib/SchemaComposer.js:153:12)
    at Schema.buildSchema (project/node_modules/.pnpm/[email protected]/node_modules/gridsome/lib/app/Schema.js:35:35)
    at Plugins.createSchema (project/node_modules/.pnpm/[email protected]/node_modules/gridsome/lib/app/Plugins.js:94:22)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

Steps to reproduce

In gridsome.config.js:

module.exports = {
  plugins: [
    {
      use: 'gridsome-source-graphql',
      options: {
        url: 'http://localhost:8888/graphql',
        fieldName: 'gqlFieldName',
        typeName: 'gqlTypeName',
      },
    },
  ],
}

url is pointing to a local GraphQL server (verified to be working correctly and consumable)

Expected result

Gridsome should consume the GraphQL properly and load the app

Actual result

Gridsome throws the error above and exits, does not start app

Environment

  System:
    OS: macOS High Sierra 10.13.6
    CPU: (8) x64 Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz
  Binaries:
    Node: 12.18.2 - ~/.nvm/versions/node/v12.18.2/bin/node
    Yarn: 1.22.4 - ~/.nvm/versions/node/v12.18.2/bin/yarn
    npm: 6.14.5 - ~/.nvm/versions/node/v12.18.2/bin/npm
  Browsers:
    Chrome: 84.0.4147.89
    Firefox: 77.0.1
    Safari: 13.1.2
  npmPackages:
    gridsome: ^0.7.0 => 0.7.19
    gridsome-source-graphql: ~1.0.2 => 1.0.2

@TerabyteTiger
Copy link
Member

Thanks for the very detailed reponse @stereokai!

To possibly help narrow it down further, does this occur when using @gridsome/source-graphql? Or only with gridsome-source-graphql?

@stereokai
Copy link

I wasn't aware of @gridsome/source-graphql, let me try it out! :)

@stereokai
Copy link

@TerabyteTiger I cleared my npm cache, completely erased node_modules, and ran npm i for a fresh installation.

Now I'm getting this:

Gridsome v0.7.19

Initializing plugins...
Load sources - 0s
Error: Cannot use GraphQLList "[gqlTypeName_Log]" from another module or realm.

Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.

https://yarnpkg.com/en/docs/selective-version-resolutions

Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.
    at instanceOf (project/node_modules/gridsome/node_modules/graphql/jsutils/instanceOf.js:28:13)
    at isListType (project/node_modules/gridsome/node_modules/graphql/type/definition.js:181:34)
    at isWrappingType (project/node_modules/gridsome/node_modules/graphql/type/definition.js:364:10)
    at getNamedType (project/node_modules/gridsome/node_modules/graphql/type/definition.js:423:12)
    at typeMapReducer (project/node_modules/gridsome/node_modules/graphql/type/schema.js:257:48)
    at typeMapReducer (project/node_modules/gridsome/node_modules/graphql/type/schema.js:286:20)
    at typeMapReducer (project/node_modules/gridsome/node_modules/graphql/type/schema.js:286:20)
    at Array.reduce (<anonymous>)
    at new GraphQLSchema (project/node_modules/gridsome/node_modules/graphql/type/schema.js:145:28)
    at NamespaceUnderFieldTransform.transformSchema (project/node_modules/@gridsome/source-graphql/transforms.js:57:12)
    at project/node_modules/graphql-tools/dist/transforms/transforms.js:11:54
    at Array.reduce (<anonymous>)
    at Object.applySchemaTransforms (project/node_modules/graphql-tools/dist/transforms/transforms.js:10:23)
    at transformSchema (project/node_modules/graphql-tools/dist/transforms/transformSchema.js:17:27)
    at GraphQLSource.namespaceSchema (project/node_modules/@gridsome/source-graphql/index.js:72:12)
    at project/node_modules/@gridsome/source-graphql/index.js:50:43

This is my package.json:

{
  "name": "project",
  "private": true,
  "scripts": {
    "build": "gridsome build",
    "develop": "gridsome develop",
    "explore": "gridsome explore"
  },
  "dependencies": {
    "@gridsome/source-graphql": "~0.1.0",
    "gridsome": "^0.7.0"
  }
}

@TerabyteTiger
Copy link
Member

That seems super weird - does this happen to be a public repo?

@stereokai
Copy link

It's a brand new project I just started yesterday, all the project has is just this configuration

@TerabyteTiger
Copy link
Member

This is super weird. I have both packages working without issue - Windows 10, PowerShell.

I started with the @gridsome package, then cleared everything out and installed gridsome-source-graphql.

These were my files -

@gridsome/source-graphql

// gridsome.config.js

module.exports = {
  siteName: "Gridsome",
  plugins: [
    {
      use: "@gridsome/source-graphql",
      options: {
        url: "https://rickandmortyapi.com/graphql/",
        fieldName: "rickandmorty",
        typeName: "RAM",
      },
    },
  ],
};
query {
   rickandmorty{
    characters {
      results {
        name
      }
    }
  }
}
// Package.json

{
  "name": "ql-test",
  "private": true,
  "scripts": {
    "build": "gridsome build",
    "develop": "gridsome develop",
    "explore": "gridsome explore"
  },
  "dependencies": {
    "@gridsome/source-graphql": "^0.1.0",
    "gridsome": "^0.7.0"
  }
}

gridsome-source-graphql

// gridsome.config.js

module.exports = {
  siteName: "Gridsome",
  plugins: [
    {
      use: "gridsome-source-graphql",
      options: {
        url: "https://rickandmortyapi.com/graphql/",
        fieldName: "rickandmorty",
        typeName: "RAM",
      },
    },
  ],
};
query {
   characters {
    results {
      name
    }
  }
}
// Package.json

{
  "name": "ql-test",
  "private": true,
  "scripts": {
    "build": "gridsome build",
    "develop": "gridsome develop",
    "explore": "gridsome explore"
  },
  "dependencies": {
    "gridsome": "^0.7.0",
    "gridsome-source-graphql": "^1.0.2"
  }
}

The only thing that stands out with your project @stereokai is that your graphQL is also on localhost - but I really don't think that's the cause of the issue.

Maybe someone with a Bash terminal can check if these files work for them?

@stereokai
Copy link

stereokai commented Jul 20, 2020

Thanks a lot of all of this!!!

I tried both options. Using your settings, I'm now getting this:

Initializing plugins...
Load sources - 0s
Error: Cannot use GraphQLObjectType "RAM_Character" from another module or realm.

Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.

https://yarnpkg.com/en/docs/selective-version-resolutions

Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.

@jackoconnor21
Copy link

jackoconnor21 commented Dec 16, 2020

Has anybody been able to figure this out? I'm using AWS Amplify (AppSync GraphQL) with Gridsome and i'm getting the same issue.
Schema must contain uniquely named types but contains multiple types named "Mutation"

I would really appreciate any help here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

9 participants