Я обнаружил, что библиотека graphql-js не позволяет зависимостям также использовать graphql.
Вы получите следующую ошибку
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.
из следующего кода
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);
Я создал небольшой репозиторий и небольшой публичный пакет npm, чтобы продемонстрировать это
repo-with-npm-dependency-on-graphql .
Эту проблему можно легко обойти, если не использовать модуль graphql в качестве зависимости в модуле. Но, конечно же, это проблема? Или это хорошо известная вещь?