mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
21 lines
574 B
TypeScript
21 lines
574 B
TypeScript
import { ApolloServer } from '@apollo/server'
|
|
import { addMocksToSchema } from '@graphql-tools/mock'
|
|
|
|
import { schema } from '@/graphql/schema'
|
|
|
|
let apolloTestServer: ApolloServer
|
|
|
|
export async function createApolloTestServer() {
|
|
if (apolloTestServer === undefined) {
|
|
apolloTestServer = new ApolloServer({
|
|
// addMocksToSchema accepts a schema instance and provides
|
|
// mocked data for each field in the schema
|
|
schema: addMocksToSchema({
|
|
schema: await schema(),
|
|
preserveResolvers: true,
|
|
}),
|
|
})
|
|
}
|
|
return apolloTestServer
|
|
}
|