Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat) Force prefix on protected types #6007

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/transforms/prefix/src/barePrefix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export default class BarePrefix implements MeshTransform {

constructor(options: MeshTransformOptions<YamlConfig.PrefixTransformConfig>) {
const { apiName, config } = options;
if (!config.force) {
config.force = [];
}
defaultIgnoreList = defaultIgnoreList.filter(x => !config.force.includes(x));
this.ignoreList = [...(config.ignore || []), ...defaultIgnoreList];
this.includeRootOperations = config.includeRootOperations === true;
this.includeTypes = config.includeTypes !== false;
Expand Down
4 changes: 4 additions & 0 deletions packages/transforms/prefix/src/wrapPrefix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export default class WrapPrefix implements MeshTransform {
throw new Error(`Transform 'prefix' has missing config: prefix`);
}

if (!config.force) {
config.force = [];
}
defaultIgnoreList = defaultIgnoreList.filter(x => !config.force.includes(x));
const ignoreList = [...(config.ignore || []), ...defaultIgnoreList];

const includeTypes = config.includeTypes !== false;
Expand Down
4 changes: 4 additions & 0 deletions packages/transforms/prefix/yaml-config.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ type PrefixTransformConfig @md {
Changes types (default: true)
"""
includeTypes: Boolean
"""
List of protected types you want to force prefix on
"""
force: [String!]
}

enum PrefixTransformMode {
Expand Down
8 changes: 8 additions & 0 deletions packages/types/src/config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3642,6 +3642,14 @@
"includeTypes": {
"type": "boolean",
"description": "Changes types (default: true)"
},
"force": {
"type": "array",
"items": {
"type": "string"
},
"additionalItems": false,
"description": "List of protected types you want to force prefix on"
}
}
},
Expand Down
4 changes: 4 additions & 0 deletions packages/types/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1380,6 +1380,10 @@ export interface PrefixTransformConfig {
* Changes types (default: true)
*/
includeTypes?: boolean;
/**
* List of protected types you want to force prefix on
*/
force?: string[];
}
/**
* Prune transform
Expand Down