diff --git a/plugins/graphql/package.json b/plugins/graphql/package.json index 564f69084d..5ed22253c3 100644 --- a/plugins/graphql/package.json +++ b/plugins/graphql/package.json @@ -40,6 +40,7 @@ "supertest": "^4.0.2" }, "files": [ - "dist" + "dist", + "schema.gql" ] } diff --git a/plugins/graphql/src/schema.gql b/plugins/graphql/schema.gql similarity index 100% rename from plugins/graphql/src/schema.gql rename to plugins/graphql/schema.gql diff --git a/plugins/graphql/src/service/router.ts b/plugins/graphql/src/service/router.ts index 09ab5270b7..69e2394f11 100644 --- a/plugins/graphql/src/service/router.ts +++ b/plugins/graphql/src/service/router.ts @@ -22,6 +22,11 @@ import fs from 'fs'; import path from 'path'; import { ApolloServer } from 'apollo-server-express'; +const schemaPath = path.resolve( + require.resolve('@backstage/plugin-graphql-backend/package.json'), + '../schema.gql', +); + export interface RouterOptions { logger: Logger; } @@ -29,10 +34,7 @@ export interface RouterOptions { export async function createRouter( options: RouterOptions, ): Promise { - const typeDefs = await fs.promises.readFile( - path.resolve(__dirname, '..', 'schema.gql'), - 'utf-8', - ); + const typeDefs = await fs.promises.readFile(schemaPath, 'utf-8'); const server = new ApolloServer({ typeDefs, logger: options.logger }); const router = Router();