chore: remove direct usage from graphql (#9316)
**What** Remove direct usage of graphql toold and instead consume it from utils to have a single entry point to graphql tooling
This commit is contained in:
committed by
GitHub
parent
f294c99c92
commit
fba78c0fb1
@@ -32,16 +32,14 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@medusajs/types": "^1.11.16",
|
||||
"@mikro-orm/core": "5.9.7",
|
||||
"awilix": "^8.0.1",
|
||||
"cross-env": "^5.2.1",
|
||||
"jest": "^29.7.0",
|
||||
"rimraf": "^5.0.1",
|
||||
"typescript": "^5.6.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@graphql-codegen/cli": "^5.0.2",
|
||||
"@graphql-codegen/typescript": "^4.0.9",
|
||||
"@graphql-tools/merge": "^9.0.0",
|
||||
"@graphql-tools/schema": "^10.0.0",
|
||||
"@medusajs/orchestration": "^0.5.7",
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
"resolve-cwd": "^3.0.0"
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { mergeTypeDefs } from "@graphql-tools/merge"
|
||||
import { makeExecutableSchema } from "@graphql-tools/schema"
|
||||
import { RemoteFetchDataCallback } from "@medusajs/orchestration"
|
||||
import {
|
||||
ConfigModule,
|
||||
@@ -18,14 +16,14 @@ import {
|
||||
} from "@medusajs/types"
|
||||
import {
|
||||
ContainerRegistrationKeys,
|
||||
createMedusaContainer,
|
||||
dynamicImport,
|
||||
GraphQLUtils,
|
||||
isObject,
|
||||
isString,
|
||||
MedusaError,
|
||||
Modules,
|
||||
ModulesSdkUtils,
|
||||
createMedusaContainer,
|
||||
dynamicImport,
|
||||
isObject,
|
||||
isString,
|
||||
promiseAll,
|
||||
} from "@medusajs/utils"
|
||||
import type { Knex } from "@mikro-orm/knex"
|
||||
@@ -37,7 +35,7 @@ import {
|
||||
RegisterModuleJoinerConfig,
|
||||
} from "./medusa-module"
|
||||
import { RemoteLink } from "./remote-link"
|
||||
import { RemoteQuery, createQuery } from "./remote-query"
|
||||
import { createQuery, RemoteQuery } from "./remote-query"
|
||||
import { MODULE_RESOURCE_TYPE, MODULE_SCOPE } from "./types"
|
||||
|
||||
const LinkModulePackage = MODULE_PACKAGE_NAMES[Modules.LINK]
|
||||
@@ -228,8 +226,11 @@ function cleanAndMergeSchema(loadedSchema) {
|
||||
const { schema: cleanedSchema, notFound } = GraphQLUtils.cleanGraphQLSchema(
|
||||
defaultMedusaSchema + loadedSchema
|
||||
)
|
||||
const mergedSchema = mergeTypeDefs(cleanedSchema)
|
||||
return { schema: makeExecutableSchema({ typeDefs: mergedSchema }), notFound }
|
||||
const mergedSchema = GraphQLUtils.mergeTypeDefs(cleanedSchema)
|
||||
return {
|
||||
schema: GraphQLUtils.makeExecutableSchema({ typeDefs: mergedSchema }),
|
||||
notFound,
|
||||
}
|
||||
}
|
||||
|
||||
function getLoadedSchema(): string {
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import { mergeTypeDefs } from "@graphql-tools/merge"
|
||||
import { makeExecutableSchema } from "@graphql-tools/schema"
|
||||
import { cleanGraphQLSchema } from "@medusajs/utils"
|
||||
import { GraphQLUtils } from "@medusajs/utils"
|
||||
|
||||
export function getEntitiesMap(loadedSchema): Map<string, any> {
|
||||
const defaultMedusaSchema = `
|
||||
scalar DateTime
|
||||
scalar JSON
|
||||
`
|
||||
const { schema } = cleanGraphQLSchema(defaultMedusaSchema + loadedSchema)
|
||||
const mergedSchema = mergeTypeDefs(schema)
|
||||
return makeExecutableSchema({ typeDefs: mergedSchema }).getTypeMap() as any
|
||||
const { schema } = GraphQLUtils.cleanGraphQLSchema(
|
||||
defaultMedusaSchema + loadedSchema
|
||||
)
|
||||
const mergedSchema = GraphQLUtils.mergeTypeDefs(schema)
|
||||
return GraphQLUtils.makeExecutableSchema({
|
||||
typeDefs: mergedSchema,
|
||||
}).getTypeMap() as any
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user