Skip to content

Commit b012690

Browse files
committed
Format code & prevent modify variable
1 parent b65c168 commit b012690

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

packages/openapi-to-graphql/src/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ const DEFAULT_OPTIONS: InternalOptions<any, any, any> = {
129129

130130
fetch: crossFetch,
131131

132-
graphQLSchemaPrefix: '',
132+
// Add prefix for each schema generated
133+
graphQLSchemaPrefix: ''
133134
}
134135

135136
/**

packages/openapi-to-graphql/src/preprocessor.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -750,16 +750,24 @@ export function createDataDef<TSource, TContext, TArgs>(
750750
return existingDataDef
751751
}
752752

753-
names = Object.fromEntries(Object.entries(names).map(([key, value]) => [key, value ? options.graphQLSchemaPrefix + '-' + value : value]))
753+
let namesFormSchema: Oas3Tools.SchemaNames = names
754+
// Add the prefix to the name
755+
if (options.graphQLSchemaPrefix) {
756+
namesFormSchema = Object.fromEntries(
757+
Object.entries(names).map(([key, value]) =>
758+
[key, value ? options.graphQLSchemaPrefix + '-' + value : value]
759+
)
760+
)
761+
}
754762

755763
// There is no preexisting data definition, so create a new one
756764

757-
const name = getSchemaName(names, data.usedTypeNames)
765+
const name = getSchemaName(namesFormSchema, data.usedTypeNames)
758766

759767
let saneInputName: string
760768
let saneName: string
761769

762-
if (name === names.fromExtension) {
770+
if (name === namesFormSchema.fromExtension) {
763771
saneName = name
764772
saneInputName = name + 'Input'
765773
} else {

0 commit comments

Comments
 (0)