(schema: string[], versionString: string)
| 46 | } |
| 47 | |
| 48 | async validateSchema(schema: string[], versionString: string): Promise<void> { |
| 49 | const versionCaption = versionString.split('-').join(' ') |
| 50 | this.logger.debug(`Validating Schema for ${versionCaption}`) |
| 51 | return new Promise<void>(async (resolve, reject) => { |
| 52 | try { |
| 53 | await this.generateAxiosRequest({ |
| 54 | path: '/admin/schema/validate', |
| 55 | data: schema.join(), |
| 56 | headers: { |
| 57 | 'Content-Type': 'text/plain', |
| 58 | }, |
| 59 | }) |
| 60 | resolve() |
| 61 | } catch (error: any) { |
| 62 | const { |
| 63 | response: { |
| 64 | data: { errors }, |
| 65 | }, |
| 66 | } = error |
| 67 | this.logger.error('Schema validation failed') |
| 68 | const errMsgs = errors.map((e: Error) => |
| 69 | e.message.replace('input:', 'line ') |
| 70 | ) |
| 71 | this.logger.error( |
| 72 | `${ |
| 73 | errMsgs.length |
| 74 | } errors found in ${versionCaption} schema. Check the following lines in the schema.graphql file:\n${errMsgs.join( |
| 75 | '\n' |
| 76 | )}` |
| 77 | ) |
| 78 | reject() |
| 79 | } |
| 80 | }) |
| 81 | } |
| 82 | |
| 83 | async setSchema(schemas: string[]): Promise<void> { |
| 84 | const data = { |
no test coverage detected