(config: ApolloConfigurationOptions, baseDir: string)
| 219 | } |
| 220 | |
| 221 | function 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 | |
| 247 | function getSubscriptionPath(config: ApolloConfigurationOptions) { |
| 248 | if (config.subscriptions && typeof config.subscriptions === 'object') { |
no test coverage detected