MCPcopy
hub / github.com/midwayjs/midway / loadTypeDefs

Function loadTypeDefs

packages/apollo/src/apolloService.ts:221–245  ·  view source on GitHub ↗
(config: ApolloConfigurationOptions, baseDir: string)

Source from the content-addressed store, hash-verified

219}
220
221function loadTypeDefs(config: ApolloConfigurationOptions, baseDir: string) {
222 const typeDefs = normalizeTypeDefs(config.typeDefs);
223 const typePaths = config.typePaths || [];
224
225 for (const pattern of typePaths) {
226 const schemaFile = resolveSchemaFilePath(baseDir, pattern);
227 if (existsSync(schemaFile) && statSync(schemaFile).isFile()) {
228 typeDefs.push(readFileSync(schemaFile, 'utf8'));
229 continue;
230 }
231
232 const patternRegExp = createSchemaPatternRegExp(pattern);
233 const files = glob(['**/*.graphql'], {
234 cwd: baseDir,
235 ignore: ['**/node_modules/**'],
236 }).filter(file =>
237 patternRegExp.test(relative(baseDir, file).replace(/\\/g, '/'))
238 );
239 for (const file of files) {
240 typeDefs.push(readFileSync(resolveSchemaFilePath(baseDir, file), 'utf8'));
241 }
242 }
243
244 return typeDefs.length <= 1 ? typeDefs[0] : typeDefs;
245}
246
247function getSubscriptionPath(config: ApolloConfigurationOptions) {
248 if (config.subscriptions && typeof config.subscriptions === 'object') {

Callers 1

createSchemaMethod · 0.85

Calls 7

normalizeTypeDefsFunction · 0.85
resolveSchemaFilePathFunction · 0.85
filterMethod · 0.80
pushMethod · 0.65
replaceMethod · 0.65
testMethod · 0.45

Tested by

no test coverage detected