a year ago
I can't update the number of instances of a service. I am trying to do that via GraphQL API.
As I understand, the logic is:
1. Update numReplicas of a service
Trigger redeploy
I am trying this request:
`
mutation updateAndDeploy($serviceId: String!, $deploymentId: String!) {
serviceInstanceUpdate(serviceId: $serviceId, input: { numReplicas: 2 })
deploymentRedeploy(id: $deploymentId) {
id
status
}
}
`
I see that redeploy is starting. In the dashboard. I can query service info to recheck:
```
query getEnvironmentServices($environmentId: String!) {
environment(id: $environmentId) {
serviceInstances {
edges {
node {
numReplicas
serviceName
region,
latestDeployment {
canRedeploy
id
status
}
}
}
}
}
}
```
Here is the output:
```
{
"data": {
"environment": {
"serviceInstances": {
"edges": [
{
"node": {
"numReplicas": 2,
"serviceName": "name",
"region": "us-west1",
"latestDeployment": {
"canRedeploy": true,
"id": "14478f6a-0d0d-4089-a790-49e568f2430e",
"status": "DEPLOYING"
}
}
}
]
}
}
}
}
```
But in the user interface, in the dashboard, I don't see changes in the number of services. I still see just one service as it was. I rechecked logs. Only one serve was started.
Why doesn't it work? In the dashboard, I can set the number of replicas per region. But GraphQL API don't do that.
7 Replies
Status changed to Awaiting User Response Railway • about 1 year ago
brody
Hello,numReplicas is deprecated, you need to use multiRegionConfig.
a year ago
Thanks. Any docs? How to structure it? How to query it to see if I set it correctly?
Status changed to Awaiting Railway Response Railway • about 1 year ago
a year ago
You can check out our graphql playground for all the structure needed -
Status changed to Awaiting User Response Railway • about 1 year ago
brody
You can check out our graphql playground for all the structure needed -https://railway.com/graphiql
a year ago
Can you please help with a specific example? I played in the playground for a long time. But still can't make it work.
I tried this:
curl -X POST https://backboard.railway.app/graphql/v2 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer TOKEN" \
-d '{
"query": "mutation updateServiceInstances($serviceId: String!, $environmentId: String, $deploymentId: String, $input: ServiceInstanceUpdateInput!) { serviceInstanceUpdate(serviceId: $serviceId, environmentId: $environmentId, deploymentId: $deploymentId, input: $input) }",
"variables": {
"environmentId": "my_env_id",
"serviceId": "my_service_id",
"deploymentId": "a27facf1-d343-4557-9d5a-3fe378f57653",
"input": {
"multiRegionConfig": {
"us-west1": {
"numReplicas": 2
}
}
}
}
}'
I also tried this:
```
mutation updateServiceInstances($serviceId: String!) {
serviceInstanceUpdate(
serviceId: $serviceId,
input: {
multiRegionConfig: {
useast4: {
numReplicas: 2
}
}
}
)
}
```
With that I was able to run the query. But it totally breaks the deployments and it is not fixable in the dashboard. I guess because the region name is not correct. I can't find how to pass it correctly.
Status changed to Awaiting Railway Response Railway • about 1 year ago
a year ago
Hello,
You can get a list of the correct regions by using the regions graphql query!
Status changed to Awaiting User Response Railway • about 1 year ago
a year ago
This is what worked for me at the end:
curl -X POST https://backboard.railway.app/graphql/v2 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer TOKEN" \
-d '{
"query": "mutation serviceInstanceUpdate($environmentId: String!, $input: ServiceInstanceUpdateInput!, $serviceId: String!) { serviceInstanceUpdate(environmentId: $environmentId, input: $input, serviceId: $serviceId) serviceInstanceDeploy(environmentId: $environmentId, serviceId: $serviceId) }",
"variables": {
"environmentId": "ENV_ID_FROM_DASHBOARD",
"input": {
"multiRegionConfig": {
"us-west1": {
"numReplicas": 3
}
}
},
"serviceId": "SERVICE_ID_FROM_DASHBOARD"
}
}'
Status changed to Awaiting Railway Response Railway • about 1 year ago
Status changed to Awaiting User Response Railway • about 1 year ago
Status changed to Solved brody • about 1 year ago