Skip to content

Commit d28d353

Browse files
committed
refactor(server): Un-vitestify dump script
Now that Redis, Elasticsearch, the JWT crypto key, and the reindex client are all lazy-initialized, the Pothos schema can be imported without triggering external service connections. Remove all vi.mock() calls from the dump script. Adds a `dump-schema` yarn script to the server package.
1 parent c3935ff commit d28d353

3 files changed

Lines changed: 15 additions & 41 deletions

File tree

packages/openneuro-server/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"scripts": {
88
"lint": "eslint src",
99
"build": "tsc -b",
10-
"start": "nodemon --watch ./dist --enable-source-maps ./dist/server.js"
10+
"start": "nodemon --watch ./dist --enable-source-maps ./dist/server.js",
11+
"dump-schema": "yarn scripts/dump-schema.ts"
1112
},
1213
"repository": {
1314
"type": "git",

packages/openneuro-server/scripts/dump-schema.test.ts

Lines changed: 0 additions & 40 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Dump the Pothos GraphQL schema to SDL.
3+
*/
4+
import { writeFileSync } from "fs"
5+
import { dirname, join } from "path"
6+
import { fileURLToPath } from "url"
7+
import { lexicographicSortSchema, printSchema } from "graphql/index.js"
8+
import schema from "../src/graphql/schema"
9+
10+
console.log("Dumping GraphQL schema to SDL...")
11+
const sdl = printSchema(lexicographicSortSchema(schema))
12+
const dir = dirname(fileURLToPath(import.meta.url))
13+
writeFileSync(join(dir, "..", "schema.graphql"), sdl + "\n")

0 commit comments

Comments
 (0)