Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
gql-server/src/server.js at master · codeday/gql-server · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
codeday
gql-server
Repository navigation
Code
Issues
Pull requests
6
(6)
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
gql-server
/
src
/
server.js
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
150 lines (140 loc) · 4.68 KB
master
Breadcrumbs
gql-server
/
src
/
server.js
Copy path
Top
File metadata and controls
Code
Blame
150 lines (140 loc) · 4.68 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import
Express
from
'express'
;
import
http
from
'http'
;
import
{
json
}
from
'body-parser'
;
import
{
ApolloServer
}
from
'apollo-server-express'
;
import
{
graphqlUploadExpress
}
from
'graphql-upload'
;
import
{
flattenDuplicateFieldSelections
}
from
'./queryFlatten'
;
import
{
SubscriptionServer
}
from
'subscriptions-transport-ws'
;
import
WebSocket
from
'ws'
;
import
{
execute
,
subscribe
}
from
'graphql'
;
import
createWordpressSchema
from
'./remotes/wordpress'
;
import
createContentfulSchema
from
'./remotes/contentful'
;
import
createGithubSchema
from
'./remotes/github'
;
import
createShowcaseSchema
from
'./remotes/showcase'
;
import
createCalendarSchema
from
'./remotes/calendar'
;
import
createLabsSchema
from
'./remotes/labs'
;
import
createAdvisorsSchema
from
'./remotes/advisors'
;
import
createTwitchSchema
from
'./remotes/twitch'
;
import
createEmailSchema
from
'./remotes/email'
;
import
createGeoSchema
from
'./remotes/geo'
;
import
createClearSchema
from
"./remotes/clear"
;
import
createImpactSchema
from
'./remotes/impact'
;
import
createAccountSchema
from
'./remotes/account'
;
import
createNotionSchema
from
'./remotes/notion'
;
import
createTermageddonSchema
from
'./remotes/termageddon'
;
import
{
weave
}
from
'./schema'
;
import
log
from
'./plugins/log'
;
const
port
=
process
.
env
.
PORT
||
4000
;
async
function
buildSchema
(
)
{
console
.
log
(
'Fetching sub-schemas...'
)
;
const
[
blog
,
showcase
,
calendar
,
labs
,
advisors
,
clear
,
cms
,
account
,
geo
,
email
,
twitch
,
github
,
notion
,
termageddon
,
impact
,
]
=
await
Promise
.
all
(
[
await
createWordpressSchema
(
process
.
env
.
WORDPRESS_URL
||
'https://wp.codeday.org/graphql'
)
,
await
createShowcaseSchema
(
process
.
env
.
SHOWCASE_URL
||
'http://showcase-gql.codeday.cloud/graphql'
,
process
.
env
.
SHOWCASE_WS
||
'ws://showcase-gql.codeday.cloud/graphql'
)
,
await
createCalendarSchema
(
process
.
env
.
CALENDAR_URL
||
'http://calendar-gql.codeday.cloud/graphql'
)
,
await
createLabsSchema
(
process
.
env
.
LABS_URL
||
'http://labs-gql.codeday.cloud/graphql'
)
,
await
createAdvisorsSchema
(
process
.
env
.
ADVISORS_URL
||
'http://advisors-gql.codeday.cloud/graphql'
)
,
await
createClearSchema
(
process
.
env
.
CLEAR_URL
||
'http://clear-gql.codeday.cloud/graphql'
)
,
await
createContentfulSchema
(
'd5pti1xheuyu'
,
process
.
env
.
CONTENTFUL_TOKEN
)
,
await
createAccountSchema
(
process
.
env
.
ACCOUNT_URL
||
"http://account-gql.codeday.cloud/graphql"
,
process
.
env
.
ACCOUNT_WS
||
"ws://account-gql.codeday.cloud/graphql"
)
,
await
createGeoSchema
(
process
.
env
.
MAXMIND_ACCOUNT
,
process
.
env
.
MAXMIND_KEY
)
,
await
createEmailSchema
(
)
,
await
createTwitchSchema
(
process
.
env
.
TWITCH_CHANNEL
,
process
.
env
.
TWITCH_CLIENT_ID
,
process
.
env
.
TWITCH_CLIENT_SECRET
)
,
await
createGithubSchema
(
process
.
env
.
GITHUB_TOKEN
,
)
,
await
createNotionSchema
(
process
.
env
.
NOTION_TOKEN
,
)
,
await
(
createTermageddonSchema
(
)
)
,
await
createImpactSchema
(
)
,
]
)
;
console
.
log
(
'...sub-schemas fetched.'
)
;
return
weave
(
{
account
,
blog
,
cms
,
showcase
,
calendar
,
email
,
twitch
,
labs
,
advisors
,
geo
,
clear
,
github
,
notion
,
termageddon
,
impact
,
}
)
;
}
export
default
async
(
)
=>
{
globalThis
.
WebSocket
=
WebSocket
;
const
schema
=
await
buildSchema
(
)
;
const
apollo
=
new
ApolloServer
(
{
schema
,
introspection
:
true
,
uploads
:
false
,
playground
:
{
endpoint
:
'/'
,
subscriptionEndpoint
:
'/subscriptions'
,
}
,
plugins
:
[
log
]
,
context
:
(
{
req
}
)
=>
(
{
headers
:
req
?.
headers
,
req
,
}
)
,
}
)
;
const
app
=
Express
(
)
;
app
.
use
(
graphqlUploadExpress
(
{
maxFileSize
:
250
*
1024
*
1024
,
maxFiles
:
3
}
)
)
;
// Parses JSON GraphQL request bodies so we can flatten duplicate fragment field
// selections (see queryFlatten.js) before they reach the stitched schema. Apollo's own
// internal body-parser (the same `body-parser` package) sees req._body is already set
// and skips re-parsing, so this doesn't double-consume the request stream.
app
.
use
(
json
(
)
)
;
app
.
use
(
(
req
,
res
,
next
)
=>
{
if
(
req
.
body
&&
typeof
req
.
body
.
query
===
'string'
)
{
req
.
body
.
query
=
flattenDuplicateFieldSelections
(
req
.
body
.
query
)
;
}
next
(
)
;
}
)
;
apollo
.
applyMiddleware
(
{
app
,
path
:
'/'
}
)
;
app
.
timeout
=
5
*
60
*
1000
;
app
.
keepAliveTimeout
=
2
*
60
*
1000
;
app
.
headersTimeout
=
5
*
60
*
1000
;
const
server
=
http
.
createServer
(
app
)
;
server
.
listen
(
port
,
(
)
=>
{
new
SubscriptionServer
(
{
schema
,
execute
,
subscribe
,
}
,
{
server
,
path
:
'/subscriptions'
}
)
;
console
.
log
(
`Listening on http://0.0.0.0:
${
port
}
`
)
;
}
)
;
}
;
You can’t perform that action at this time.