MCPcopy Create free account
hub / github.com/keystonejs/keystone / createSystem

Function createSystem

packages/core/src/lib/createSystem.ts:203–254  ·  view source on GitHub ↗
(config_: KeystoneConfig)

Source from the content-addressed store, hash-verified

201}
202
203export function createSystem (config_: KeystoneConfig) {
204 const config = resolveDefaults(config_)
205 const lists = initialiseLists(config)
206 const adminMeta = createAdminMeta(config, lists)
207 const graphQLSchema = createGraphQLSchema(config, lists, adminMeta, false)
208 const graphQLSchemaSudo = getSudoGraphQLSchema(config)
209
210 return {
211 config,
212 graphQLSchema,
213 graphQLSchemaSudo,
214 adminMeta,
215 lists,
216
217 getPaths: (cwd: string) => {
218 return getSystemPaths(cwd, config)
219 },
220
221 getKeystone: (PM: any) => {
222 const prePrismaClient = new PM.PrismaClient({
223 datasourceUrl: formatUrl(config.db.provider, config.db.url),
224 log: config.db.enableLogging
225 })
226
227 const prismaClient = config.db.extendPrismaClient(injectNewDefaults(prePrismaClient, lists))
228 const context = createContext({
229 config,
230 lists,
231 graphQLSchema,
232 graphQLSchemaSudo,
233 prismaClient,
234 prismaTypes: {
235 DbNull: PM.Prisma.DbNull,
236 JsonNull: PM.Prisma.JsonNull,
237 },
238 })
239
240 return {
241 // TODO: replace with server.onStart, remove in breaking change
242 async connect () {
243 await (prismaClient as any).$connect()
244 await config.db.onConnect?.(context)
245 },
246 // TODO: only used by tests, remove in breaking change
247 async disconnect () {
248 await (prismaClient as any).$disconnect()
249 },
250 context,
251 }
252 },
253 }
254}
255
256export type System = ReturnType<typeof createSystem>

Callers 11

getContextFunction · 0.90
startFunction · 0.90
prismaFunction · 0.90
initKeystoneFunction · 0.90
buildFunction · 0.90
migrateCreateFunction · 0.90
migrateApplyFunction · 0.90
setupTestEnvFunction · 0.85
getPrismaSchemaFunction · 0.85
getSchemaFunction · 0.85
tryfFunction · 0.85

Calls 9

resolveDefaultsFunction · 0.90
initialiseListsFunction · 0.90
createAdminMetaFunction · 0.90
createGraphQLSchemaFunction · 0.90
createContextFunction · 0.90
getSudoGraphQLSchemaFunction · 0.85
getSystemPathsFunction · 0.85
formatUrlFunction · 0.85
injectNewDefaultsFunction · 0.85

Tested by 2

getSchemaFunction · 0.68
tryfFunction · 0.68