diff --git a/.changeset/seven-frogs-stare.md b/.changeset/seven-frogs-stare.md new file mode 100644 index 0000000000..293000deeb --- /dev/null +++ b/.changeset/seven-frogs-stare.md @@ -0,0 +1,5 @@ +--- +'@frontside/backstage-plugin-graphql-backend-module-catalog': patch +--- + +Add ability to override Catalog GraphQL module schema diff --git a/plugins/graphql-backend-module-catalog/src/catalog/catalog.ts b/plugins/graphql-backend-module-catalog/src/catalog/catalog.ts index bffca45b38..8477a533b1 100644 --- a/plugins/graphql-backend-module-catalog/src/catalog/catalog.ts +++ b/plugins/graphql-backend-module-catalog/src/catalog/catalog.ts @@ -1,4 +1,4 @@ -import { createModule } from 'graphql-modules'; +import { TypeDefs, createModule } from 'graphql-modules'; import { loadFilesSync } from '@graphql-tools/load-files'; import { resolvePackagePath } from '@backstage/backend-common'; import { Relation } from '../relation'; @@ -11,14 +11,14 @@ const catalogSchemaPath = resolvePackagePath( ); /** @public */ -export const Catalog = (): GraphQLModule => ({ +export const Catalog = ({ typeDefs }: { typeDefs?: TypeDefs } = {}): GraphQLModule => ({ mappers: { ...Relation().mappers }, postTransform: Relation().postTransform, module: createModule({ id: 'catalog-entities', typeDefs: [ ...Relation().module.typeDefs, - ...loadFilesSync(catalogSchemaPath), + ...typeDefs ? [typeDefs].flat() : loadFilesSync(catalogSchemaPath), ], resolvers: { ...Relation().module.config.resolvers, diff --git a/plugins/graphql-backend-module-catalog/src/catalogModule.ts b/plugins/graphql-backend-module-catalog/src/catalogModule.ts index 6b16913e77..895f611ab6 100644 --- a/plugins/graphql-backend-module-catalog/src/catalogModule.ts +++ b/plugins/graphql-backend-module-catalog/src/catalogModule.ts @@ -21,7 +21,7 @@ export const graphqlModuleCatalog = createBackendModule({ context: graphqlContextExtensionPoint, }, async init({ catalog, modules, loaders, context }) { - modules.addModules([Catalog]); + modules.addModules([Catalog()]); loaders.addLoaders(createCatalogLoader(catalog)); context.setContext(ctx => ({ ...ctx, catalog })); },