uploadSchema
Publish a new schema version, with a dry run and an explicit opt-in for breaking changes.
uploadSchema(input: SchemaUploadInput): Promise<SchemaUploadResult>uploadSchema(request: SchemaUploadRequest): Promise<SchemaUploadResponse>Parameters
schemaDocumentstringrequiredThe document.
dryRunbooleanoptionalRun the whole upload path, including the compatibility check, and store nothing.
allowBreakingbooleanoptionalAccept a document that is not backward compatible. Without it, a breaking change is refused.
Returns
namespace / schemaVersion—alwaysWhere it landed.
backwardCompatiblebooleanalwaysWhether the new version can read what the old one wrote. false here with breaking changes allowed means you took the break deliberately.
validationErrorsSchemaError[]alwaysEmpty on success.
Example
const check = await brain.validateSchema({ schemaDocument: doc });
if (check.validationErrors.length > 0) {
for (const e of check.validationErrors) {
console.error(`${e.line}:${e.column} ${e.code} ${e.message}`);
}
return;
}
const up = await brain.uploadSchema({ schemaDocument: doc });
if (!up.backwardCompatible) console.warn("breaking change accepted");This verb resolves with a populated validationErrors array rather than
throwing. Code that only wraps the call in a try/catch treats an invalid
schema as a successful one. Check the array.
Uploading a schema needs the SchemaUpload grant when the request carries an
act_as selector. See act_as.
Was this page helpful?