I have found that the graphql-js library does not allow dependencies to also use graphql.
You would get the following error
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.
from the following code
const express = require('express');
const graphqlHTTP = require('express-graphql');
const { GraphQLSchema } = require('graphql');
// the module graphql-test-mod-obj-type' has
// graphql as a depenedency
const myType = require('graphql-test-mod-obj-type');
const app = express();
const schema = new GraphQLSchema({ query: myType })
app.use('/graphql', graphqlHTTP({
schema,
graphiql: true
}));
app.listen(4000);
I created a small repo and a small public npm package to demonstrate this repo-with-npm-dependency-on-graphql .
This can be quite easily worked around by not having the graphql module as a dependency in the module. But surely this is an issue? Or is this a well known thing?