mirror of
https://github.com/IT4Change/gradido.git
synced 2026-01-20 20:01:31 +00:00
build schema in graphql folder not in index
This commit is contained in:
parent
91849b5130
commit
4601c3df34
14
backend/src/graphql/index.ts
Normal file
14
backend/src/graphql/index.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { GraphQLSchema } from 'graphql'
|
||||
import { buildSchema } from 'type-graphql'
|
||||
|
||||
import resolvers from './resolvers'
|
||||
import { isAuthorized } from '../auth/auth'
|
||||
|
||||
const schema = async (): Promise<GraphQLSchema> => {
|
||||
return buildSchema({
|
||||
resolvers: resolvers(),
|
||||
authChecker: isAuthorized,
|
||||
})
|
||||
}
|
||||
|
||||
export { schema }
|
||||
@ -3,7 +3,6 @@
|
||||
import 'reflect-metadata'
|
||||
import express from 'express'
|
||||
import cors from 'cors'
|
||||
import { buildSchema } from 'type-graphql'
|
||||
import { ApolloServer } from 'apollo-server-express'
|
||||
|
||||
// config
|
||||
@ -14,10 +13,7 @@ import connection from './typeorm/connection'
|
||||
import getDBVersion from './typeorm/getDBVersion'
|
||||
|
||||
// graphql
|
||||
import resolvers from './graphql/resolvers'
|
||||
|
||||
// auth
|
||||
import { isAuthorized } from './auth/auth'
|
||||
import { schema } from './graphql'
|
||||
|
||||
// TODO implement
|
||||
// import queryComplexity, { simpleEstimator, fieldConfigEstimator } from "graphql-query-complexity";
|
||||
@ -54,14 +50,6 @@ async function main() {
|
||||
)
|
||||
}
|
||||
|
||||
const schema = await buildSchema({
|
||||
resolvers: resolvers(),
|
||||
authChecker: isAuthorized,
|
||||
})
|
||||
|
||||
// Graphiql interface
|
||||
const playground = CONFIG.GRAPHIQL
|
||||
|
||||
// Express Server
|
||||
const server = express()
|
||||
|
||||
@ -89,7 +77,12 @@ async function main() {
|
||||
]
|
||||
|
||||
// Apollo Server
|
||||
const apollo = new ApolloServer({ schema, playground, context, plugins })
|
||||
const apollo = new ApolloServer({
|
||||
schema: await schema(),
|
||||
playground: CONFIG.GRAPHIQL,
|
||||
context,
|
||||
plugins,
|
||||
})
|
||||
apollo.applyMiddleware({ app: server })
|
||||
|
||||
// Start Server
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user