Co-authored-by: domfelipe <53182096+domfelipe@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot] 2026-04-23 20:57:43 +00:00
parent ab19306a9e
commit db38398c21
4 changed files with 190 additions and 0 deletions

View file

@ -135,6 +135,36 @@ export async function deployRailwayService(opts: {
}
}
/**
* Upsert de várias variáveis de uma vez no serviço Railway.
* Mais eficiente que múltiplos variableUpsert sequenciais.
*/
export async function upsertRailwayVariableCollection(opts: {
token: string;
serviceId: string;
environmentId: string;
projectId: string;
variables: Record<string, string>;
replace?: boolean;
}): Promise<void> {
const mutation = `
mutation VariableCollectionUpsert($input: VariableCollectionUpsertInput!) {
variableCollectionUpsert(input: $input)
}
`;
const input = {
projectId: opts.projectId,
environmentId: opts.environmentId,
serviceId: opts.serviceId,
variables: opts.variables,
replace: opts.replace ?? false,
};
const res = await railwayQuery(mutation, { input }, opts.token);
if (res.errors?.length) {
throw new Error(`variableCollectionUpsert failed: ${JSON.stringify(res.errors)}`);
}
}
/**
* Upsert de uma única variável de ambiente no serviço Railway.
* Para "remover" o efeito de uma variável boolean, passe value="" (string vazia).