Mirror of https://github.com/roostorg/coop
github.com/roostorg/coop
1const { pascalCase } = require('change-case-all');
2
3// Add 'GraphQL' prefix to all generated GraphQL types
4function AddGraphQLPrefix(str) {
5 const result = pascalCase(str);
6 if (result.length === 0) {
7 // pascalCase function has a bug that, if you pass _ to it,
8 // it will return an empty string. In this case, just return
9 // the original
10 return str;
11 }
12
13 // Unsure why, but for some reason 'GraphQl' is being inserted
14 // into the middle of some types. This is hacky but should work
15 // to remove that when it happens.
16 return `GQL${result.replace('Gql', '')}`;
17}
18
19module.exports = AddGraphQLPrefix;