MCPcopy Create free account
hub / github.com/hashintel/hash / createApolloServer

Function createApolloServer

apps/hash-api/src/graphql/create-apollo-server.ts:136–214  ·  view source on GitHub ↗
({
  graphApi,
  cache,
  emailTransporter,
  uploadProvider,
  temporalClient,
  vaultClient,
  logger,
  statsd,
  httpServer,
}: CreateApolloServerParams)

Source from the content-addressed store, hash-verified

134}
135
136export const createApolloServer = async ({
137 graphApi,
138 cache,
139 emailTransporter,
140 uploadProvider,
141 temporalClient,
142 vaultClient,
143 logger,
144 statsd,
145 httpServer,
146}: CreateApolloServerParams) => {
147 // go via makeExecutableSchema to set inheritResolversFromInterfaces
148 const combinedSchema = makeExecutableSchema({
149 typeDefs: schema,
150 resolvers,
151 inheritResolversFromInterfaces: true,
152 });
153
154 const dataSources: GraphQLContext["dataSources"] = {
155 graphApi,
156 uploadProvider,
157 };
158
159 const server = new ApolloServer<GraphQLContext>({
160 schema: combinedSchema,
161 cache: new KeyvAdapter(cache),
162 logger: logger.child({ service: "graphql" }),
163 introspection: !isProdEnv,
164 includeStacktraceInErrorResponses: !isProdEnv,
165 plugins: [
166 isProdEnv
167 ? ApolloServerPluginLandingPageProductionDefault({ footer: false })
168 : ApolloServerPluginLandingPageLocalDefault({
169 embed: {
170 endpointIsEditable: false,
171 initialState: {
172 pollForSchemaUpdates: false,
173 },
174 runTelemetry: false,
175 },
176 document: `{
177 me {
178 subgraph {
179 vertices
180 }
181 }
182}`,
183 }),
184 statsPlugin({ statsd }),
185 ApolloServerPluginDrainHttpServer({ httpServer }),
186 ],
187 });
188
189 // Note: the server must be started before the middleware can be applied
190 await server.start();
191
192 const middleware = expressMiddleware(server, {
193 context: async ({ req, res }): Promise<GraphQLContext> => ({

Callers 1

mainFunction · 0.90

Calls 6

getActorIdFromRequestFunction · 0.90
statsPluginFunction · 0.85
childMethod · 0.80
startMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected