mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-18 15:04:59 +00:00
use upsert collection instead of upserting every variable
This commit is contained in:
@@ -75,7 +75,7 @@ class RailwayPublicClient {
|
||||
async send<T extends TRailwayResponse>(
|
||||
query: string,
|
||||
options: RailwaySendReqOptions,
|
||||
variables: Record<string, string | Record<string, string>> = {},
|
||||
variables: Record<string, unknown> = {},
|
||||
retryAttempt: number = 0
|
||||
): Promise<T["data"] | undefined> {
|
||||
const body = {
|
||||
@@ -117,6 +117,22 @@ class RailwayPublicClient {
|
||||
}
|
||||
}
|
||||
|
||||
async getDeployments(config: RailwaySendReqOptions, variables: { input: { serviceId: string; environmentId: string }, first?: number }) {
|
||||
return await this.send<TRailwayResponse<{ deployments: { edges: { node: { id: string } }[] } }>>(
|
||||
`query deployments($input: DeploymentListInput!, $first: Int) { deployments(first: $first, input: $input) { edges { node { id } } } }`,
|
||||
config,
|
||||
variables
|
||||
);
|
||||
}
|
||||
|
||||
async redeployDeployment(config: RailwaySendReqOptions, variables: { input: { deploymentId: string } }) {
|
||||
return await this.send<TRailwayResponse<{ deploymentRedeploy: { id: string } }>>(
|
||||
`mutation deploymentRedeploy($deploymentId: String!) { deploymentRedeploy(id: $deploymentId) { id } }`,
|
||||
config,
|
||||
{ deploymentId: variables.input.deploymentId }
|
||||
);
|
||||
}
|
||||
|
||||
async getSubscriptionType(config: RailwaySendReqOptions & { projectId: string }) {
|
||||
const res = await this.send(
|
||||
`query project($projectId: String!) { project(id: $projectId) { subscriptionType }}`,
|
||||
@@ -213,7 +229,7 @@ class RailwayPublicClient {
|
||||
|
||||
async deleteVariable(
|
||||
config: RailwaySendReqOptions,
|
||||
variables: { input: { projectId: string; environmentId: string; name: string; serviceId?: string } }
|
||||
variables: { input: { projectId: string; environmentId: string; name: string; skipDeploys?: boolean; serviceId?: string } }
|
||||
) {
|
||||
await this.send<TRailwayResponse<{ variables: Record<string, string> }>>(
|
||||
`mutation variableDelete($input: VariableDeleteInput!) { variableDelete(input: $input) }`,
|
||||
@@ -222,6 +238,17 @@ class RailwayPublicClient {
|
||||
);
|
||||
}
|
||||
|
||||
async upsertCollection(
|
||||
config: RailwaySendReqOptions,
|
||||
variables: { input: { projectId: string; environmentId: string; variables: Record<string, string>; skipDeploys?: boolean; serviceId?: string, replace?: boolean } }
|
||||
) {
|
||||
return await this.send<TRailwayResponse<boolean>>(
|
||||
`mutation variableCollectionUpsert($input: VariableCollectionUpsertInput!) { variableCollectionUpsert(input: $input) }`,
|
||||
config,
|
||||
variables,
|
||||
);
|
||||
}
|
||||
|
||||
async upsertVariable(
|
||||
config: RailwaySendReqOptions,
|
||||
variables: { input: { projectId: string; environmentId: string; name: string; value: string; serviceId?: string } }
|
||||
|
||||
Reference in New Issue
Block a user