UNPKG

4.24 kBSource Map (JSON)View Raw
1{"version":3,"file":"index.esm.js","sources":["../../../dist/transforms/naming-convention/src/index.js"],"sourcesContent":["import { RenameTypes, RenameObjectFields, RenameRootFields, RenameRootTypes, RenameInputObjectFields, TransformEnumValues, RenameInterfaceFields, } from '@graphql-tools/wrap';\nimport { applySchemaTransforms, applyRequestTransforms, applyResultTransforms, } from '@graphql-tools/utils';\nimport { camelCase, capitalCase, constantCase, dotCase, headerCase, noCase, paramCase, pascalCase, pathCase, sentenceCase, snakeCase, } from 'change-case';\nimport { upperCase } from 'upper-case';\nimport { lowerCase } from 'lower-case';\nconst NAMING_CONVENTIONS = {\n camelCase,\n capitalCase,\n constantCase,\n dotCase,\n headerCase,\n noCase,\n paramCase,\n pascalCase,\n pathCase,\n sentenceCase,\n snakeCase,\n upperCase,\n lowerCase,\n};\nexport default class NamingConventionTransform {\n constructor(options) {\n this.transforms = [];\n if (options.config.typeNames) {\n const namingConventionFn = NAMING_CONVENTIONS[options.config.typeNames];\n this.transforms.push(new RenameTypes(typeName => namingConventionFn(typeName)), new RenameRootTypes(typeName => namingConventionFn(typeName)));\n }\n if (options.config.fieldNames) {\n const namingConventionFn = NAMING_CONVENTIONS[options.config.fieldNames];\n this.transforms.push(new RenameObjectFields((_, fieldName) => namingConventionFn(fieldName)), new RenameRootFields((_, fieldName) => namingConventionFn(fieldName)), new RenameInputObjectFields((_, fieldName) => namingConventionFn(fieldName)), new RenameInterfaceFields((_, fieldName) => namingConventionFn(fieldName)));\n }\n if (options.config.enumValues) {\n const namingConventionFn = NAMING_CONVENTIONS[options.config.enumValues];\n this.transforms.push(new TransformEnumValues((typeName, externalValue, enumValueConfig) => [\n namingConventionFn(externalValue),\n enumValueConfig,\n ]));\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.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