import { describe, beforeEach, afterEach, it, expect } from 'vitest'; import { Express } from 'express'; import path from 'path'; import request from 'supertest'; import { init } from '../app'; import { Config } from '../app'; import { remoteApplication1 } from '../test/remote-graphql-1'; import { remoteApplication2 } from '../test/remote-graphql-2'; describe('allow-all', () => { let remote1: any; let remote2: any; let app: { app: Express, stop: () => void }; beforeEach(async () => { const config: Config = { reloadInterval: 5000, list: [ { name: "Movies!", url: "http://localhost:8008/graphql", prefix: "movies_" }, { name: "Books!", url: "http://localhost:8009/graphql", prefix: "books_" } ], dangerouslyExposeEverything: true, allowedQueriesAndMutations: ['getMovies'], }; remote1 = await remoteApplication1(); remote2 = await remoteApplication2(); app = await init({ config }); }); afterEach(async () => { app.stop(); remote1.server.close(); remote2.server.close(); }); it('should enable access multiple remote services schemas', async () => { const result = await request(app.app) .post('/graphql') .set('x-test', 'test') .set('foo', 'bar') .send({ query: ` query { getBooks { books { title } } } `, }); const { body, status } = result; expect(status).toEqual(200); expect(body.data.getBooks.books).toMatchObject([ {title: 'The Awakening'}, {title: 'City of Glass'}, {title: 'The Great Gatsby'}, ]); }); });