UNPKG

2.93 kBSource Map (JSON)View Raw
1{"version":3,"file":"index.esm.js","sources":["../../../dist/transforms/prefix/src/index.js"],"sourcesContent":["import { RenameTypes, RenameRootFields } from '@graphql-tools/wrap';\nimport { applySchemaTransforms, applyRequestTransforms, applyResultTransforms, } from '@graphql-tools/utils';\nexport default class PrefixTransform {\n constructor(options) {\n this.transforms = [];\n const { apiName, config } = options;\n let prefix = null;\n if (config.value) {\n prefix = config.value;\n }\n else if (apiName) {\n prefix = `${apiName}_`;\n }\n if (!prefix) {\n throw new Error(`Transform 'prefix' has missing config: prefix`);\n }\n const ignoreList = config.ignore || [];\n this.transforms.push(new RenameTypes(typeName => (ignoreList.includes(typeName) ? typeName : `${prefix}${typeName}`)));\n if (config.includeRootOperations) {\n this.transforms.push(new RenameRootFields((typeName, fieldName) => ignoreList.includes(typeName) || ignoreList.includes(`${typeName}.${fieldName}`)\n ? fieldName\n : `${prefix}${fieldName}`));\n }\n }\n transformSchema(schema) {\n return applySchemaTransforms(schema, this.transforms);\n }\n transformRequest(request) {\n return applyRequestTransforms(request, this.transforms);\n }\n transformResult(result) {\n return applyResultTransforms(result, this.transforms);\n }\n}\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;AAEe,MAAM,eAAe,CAAC;AACrC,IAAI,WAAW,CAAC,OAAO,EAAE;AACzB,QAAQ,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;AAC7B,QAAQ,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;AAC5C,QAAQ,IAAI,MAAM,GAAG,IAAI,CAAC;AAC1B,QAAQ,IAAI,MAAM,CAAC,KAAK,EAAE;AAC1B,YAAY,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC;AAClC,SAAS;AACT,aAAa,IAAI,OAAO,EAAE;AAC1B,YAAY,MAAM,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;AACnC,SAAS;AACT,QAAQ,IAAI,CAAC,MAAM,EAAE;A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