fix: Generated types interface name (#9307)
**What** Fix interface name in the output generated types
This commit is contained in:
committed by
GitHub
parent
16d2fdbfe6
commit
6e5d007837
@@ -1,4 +1,4 @@
|
||||
import { FileSystem, toCamelCase } from "@medusajs/utils"
|
||||
import { FileSystem } from "@medusajs/utils"
|
||||
import { GraphQLSchema } from "graphql/type"
|
||||
import { parse, printSchema } from "graphql"
|
||||
import { codegen } from "@graphql-codegen/core"
|
||||
@@ -43,11 +43,13 @@ function buildEntryPointsTypeMap({
|
||||
async function generateTypes({
|
||||
outputDir,
|
||||
filename,
|
||||
interfaceName,
|
||||
config,
|
||||
joinerConfigs,
|
||||
}: {
|
||||
outputDir: string
|
||||
filename: string
|
||||
interfaceName: string
|
||||
config: Parameters<typeof codegen>[0]
|
||||
joinerConfigs: ModuleJoinerConfig[]
|
||||
}) {
|
||||
@@ -56,8 +58,6 @@ async function generateTypes({
|
||||
let output = await codegen(config)
|
||||
const entryPoints = buildEntryPointsTypeMap({ schema: output, joinerConfigs })
|
||||
|
||||
const interfaceName = toCamelCase(filename)
|
||||
|
||||
const remoteQueryEntryPoints = `
|
||||
declare module '@medusajs/types' {
|
||||
interface ${interfaceName} {
|
||||
@@ -92,11 +92,13 @@ export async function gqlSchemaToTypes({
|
||||
outputDir,
|
||||
filename,
|
||||
joinerConfigs,
|
||||
interfaceName,
|
||||
}: {
|
||||
schema: GraphQLSchema
|
||||
outputDir: string
|
||||
filename: string
|
||||
joinerConfigs: ModuleJoinerConfig[]
|
||||
interfaceName: string
|
||||
}) {
|
||||
const config = {
|
||||
documents: [],
|
||||
@@ -122,5 +124,11 @@ export async function gqlSchemaToTypes({
|
||||
},
|
||||
}
|
||||
|
||||
await generateTypes({ outputDir, filename, config, joinerConfigs })
|
||||
await generateTypes({
|
||||
outputDir,
|
||||
filename,
|
||||
config,
|
||||
joinerConfigs,
|
||||
interfaceName,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ async function start({ port, directory, types }) {
|
||||
await gqlSchemaToTypes({
|
||||
outputDir: outputDirGeneratedTypes,
|
||||
filename: "remote-query-entry-points",
|
||||
interfaceName: "RemoteQueryEntryPoints",
|
||||
schema: gqlSchema,
|
||||
joinerConfigs: MedusaModule.getAllJoinerConfigs(),
|
||||
})
|
||||
|
||||
@@ -16,6 +16,7 @@ export async function gqlSchemaToTypes(schema: string) {
|
||||
await ModulesSdkGqlSchemaToTypes({
|
||||
schema: executableSchema,
|
||||
filename,
|
||||
interfaceName: "IndexServiceEntryPoints",
|
||||
outputDir: dir,
|
||||
joinerConfigs: MedusaModule.getAllJoinerConfigs(),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user