Skip to content

Commit 7bd9b00

Browse files
fix: broken dependency toPascalCase (#7)
* Add pascal-case as dependency Co-authored-by: Kees van Lierop <[email protected]>
1 parent 7ba4e9a commit 7bd9b00

File tree

3 files changed

+210
-21
lines changed

3 files changed

+210
-21
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
],
2424
"dependencies": {
2525
"@graphql-codegen/plugin-helpers": "^1.8.1",
26-
"casual": "^1.6.2"
26+
"casual": "^1.6.2",
27+
"pascal-case": "^3.1.1"
2728
},
2829
"peerDependencies": {
2930
"graphql": "^14.0.0"

src/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
import { printSchema, parse, visit, ASTKindToNode, NamedTypeNode, TypeNode, VisitFn } from 'graphql';
22
import casual from 'casual';
3-
import { toPascalCase, PluginFunction } from '@graphql-codegen/plugin-helpers';
3+
import { PluginFunction } from '@graphql-codegen/plugin-helpers';
4+
import { pascalCase } from 'pascal-case';
5+
6+
export function toPascalCase(str: string) {
7+
if (str.charAt(0) === '_') {
8+
return str.replace(/^(_*)(.*)/, (_match, underscorePrefix, typeName) => `${underscorePrefix}${pascalCase(typeName || '')}`);
9+
}
10+
11+
return pascalCase(str || '');
12+
}
413

514
const toMockName = (name: string) => {
615
const isVowel = name.match(/^[AEIO]/);

0 commit comments

Comments
 (0)