Mirror: Modular GraphQL.js import paths without the hassle.

Add import overrides for breaking changes in v15

+6
import-map-overrides.json
···
···
+
{
+
"visitWithTypeInfo": {
+
"local": "visitWithTypeInfo",
+
"from": "graphql"
+
}
+
}
+7 -1
index.js
···
module.exports = function babelPluginModularGraphql({ types: t }) {
const importMap = require('./import-map.json');
const PKG_NAME = 'graphql';
return {
···
const imports = node.specifiers.reduce((acc, specifier) => {
if (t.isImportSpecifier(specifier)) {
const imported = specifier.imported.name;
-
const declaration = importMap[imported];
const from = declaration ? declaration.from : PKG_NAME;
if (!acc[from]) {
acc[from] = t.importDeclaration([], t.stringLiteral(from));
···
module.exports = function babelPluginModularGraphql({ types: t }) {
const importMap = require('./import-map.json');
+
const importMapOverrides = require('./import-map-overrides.json');
const PKG_NAME = 'graphql';
return {
···
const imports = node.specifiers.reduce((acc, specifier) => {
if (t.isImportSpecifier(specifier)) {
const imported = specifier.imported.name;
+
+
let declaration = importMap[imported];
+
if (importMapOverrides[imported]) {
+
declaration = importMapOverrides[imported];
+
}
+
const from = declaration ? declaration.from : PKG_NAME;
if (!acc[from]) {
acc[from] = t.importDeclaration([], t.stringLiteral(from));