File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env node
2
+
3
+ /*
4
+ Local GraphQL Playground for static schema (SDL) development/testing.
5
+ - Runs a standalone server on http://localhost:4000/graphql
6
+ - Uses only the static SDL (schema-static.mjs) and stub scalars
7
+ - Does not use dynamic data or production API logic
8
+ - Useful for viewing schema docs and testing queries against the static schema
9
+ - Not used in production or deployment
10
+ */
11
+
12
+ import http from 'http'
13
+ import { createYoga } from 'graphql-yoga'
14
+ import { makeExecutableSchema } from '@graphql-tools/schema'
15
+ import staticSDL from './schema-static.mjs'
16
+
17
+ // Stubs for custom scalars referenced in staticSDL
18
+ const stubSDL = `
19
+ scalar LanguageCode
20
+ scalar ItemType
21
+ scalar ItemCategoryName
22
+ scalar HandbookCategoryName
23
+ `
24
+
25
+ // Build schema from static SDL and stubs
26
+ const schema = makeExecutableSchema ( {
27
+ typeDefs : [ staticSDL , stubSDL ] ,
28
+ resolvers : { } ,
29
+ } )
30
+
31
+ // Enable GraphiQL at /graphql for local exploration
32
+ const yoga = createYoga ( {
33
+ schema,
34
+ graphiql : true ,
35
+ } )
36
+
37
+ // Start HTTP server on port 4000
38
+ const server = http . createServer ( yoga )
39
+ const PORT = 4000
40
+ server . listen ( PORT , ( ) => {
41
+ console . log (
42
+ `🚀 GraphQL Playground running at http://localhost:${ PORT } /graphql`
43
+ )
44
+ } )
You can’t perform that action at this time.
0 commit comments