MCPcopy Index your code
hub / github.com/cloudgraphdev/cli / validateSchema

Method validateSchema

src/storage/dgraph/index.ts:48–81  ·  view source on GitHub ↗
(schema: string[], versionString: string)

Source from the content-addressed store, hash-verified

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 = {

Callers 1

runMethod · 0.80

Calls 1

generateAxiosRequestMethod · 0.80

Tested by

no test coverage detected