Skip to content

Commit

Permalink
Add ability to override Catalog GraphQL module schema (#400)
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitriy Lazarev <[email protected]>
  • Loading branch information
wKich authored Apr 18, 2024
1 parent 2c40277 commit d4fe95d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/seven-frogs-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@frontside/backstage-plugin-graphql-backend-module-catalog': patch
---

Add ability to override Catalog GraphQL module schema
6 changes: 3 additions & 3 deletions plugins/graphql-backend-module-catalog/src/catalog/catalog.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
},
Expand Down

0 comments on commit d4fe95d

Please sign in to comment.