Cannot use GraphQLScalarType "String" from another module or realm

https://composedb.js.org/docs/0.2.x/first-composite
composedb graphql:server --ceramic-url=http://localhost:7007 --graphiql --port=5000 runtime-composite.json

I got:
:heavy_multiplication_x: Cannot use GraphQLScalarType “String” 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.

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.

Nodejs
v16.13.0
@composedb/cli
v0.2.4

I’ve just joined the forum to report the same error. The way I came across this issue is by interacting with GraphiQL using the API whereas the issue raised by IvanH was triggered with the CLI approach.

I came across the error following the ‘Your first composite’ instructions here: Your first composite | ComposeDB on Ceramic
I’m at the ‘Interacting using GraphiQL’ stage and trying to run the script from the ‘Using the API’ tab:

import { serveEncodedDefinition } from '@composedb/devtools-node'

const server = await serveEncodedDefinition({
  ceramicURL: 'http://localhost:7007',
  graphiql: true,
  path: new URL('my-first-composite.json', import.meta.url),
  port: 5001,
})

console.log(`Server started on ${server.url}`)

process.on('SIGTERM', () => {
  server.close(() => {

    console.log('Server stopped')
  })
})

I’m using Node v16.14.0 and @composedb/cli v0.3.0-rc.1.

Any help resolving this would be much appreciated!

1 Like

Some further insight is provided by Yarn which tries to resolve some of the issues:

➤ YN0000: ┌ Resolution step
➤ YN0060: │ @composedb/devtools-node@npm:0.3.0 [de8d0] provides graphql (p14a59) with version 16.6.0, which doesn't satisfy what express-graphql requests
➤ YN0002: │ @composedb/devtools@npm:0.3.0 doesn't provide graphql (p0e669), requested by @graphql-tools/utils
➤ YN0002: │ @composedb/devtools@npm:0.3.0 doesn't provide graphql (p69bf2), requested by @graphql-tools/schema

You can try via npm instead of yarn

@IvanH Did you manage to resolve the issue with npm?

@IvanH and anyone else who comes across this issue - I managed to solve the problem by using pnpm and following the instructions again from here: Ceramic configuration | ComposeDB on Ceramic

The issue with the GraphQL dependencies is still mentioned by pnpm however when running the script the GraphQL server starts without issue. The working package.json looks like this:

{
  "name": "ceramic-composedb",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "devDependencies": {
    "@composedb/devtools": "^0.3.0",
    "@composedb/devtools-node": "^0.3.0",
    "@composedb/types": "^0.3.0",
    "@types/node": "^18.8.2"
  },
  "dependencies": {
    "@ceramicnetwork/http-client": "^2.5.0",
    "@composedb/client": "^0.3.0",
    "key-did-provider-ed25519": "^2.0.1",
    "key-did-resolver": "^2.1.3",
    "uint8arrays": "^3.1.0"
  },
  "type": "module"
}

Hopefully this will resolve the issue for you as well @IvanH if you haven’t fixed it already

I faced same issue and it is true that works with pnpm as solution states, but not working for yarn or npm for me.

Does anybody know the issue in detail here?

Mainly asking because the other 2 version managers (npm and yarn) should work too. For example I use npm in my computer mainly and I would like to keep using it instead of using 2 version managers in same system (npm and pnpm).

Having same issue as you mentioned (paste it here):

✖ Cannot use GraphQLScalarType "Int" 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.

I also used resolutions to use only one version of graphql and same issue (and checked that I had one version installed only in my project).

Was anybody able to install and run composedb successfully using npm or yarn?

Thanks a lot!