R
Railway6mo ago
Faolain

Railway GraphQL Question - getting service names from environments query

Sorry if this is easy to find but I'm not capable of seeing how this can be done, I have the following graphql query
query environments($projectId: String!) {
environments(projectId: $projectId) {
edges {
node {
id
name
serviceInstances {
edges {
node {
id
serviceId
domains {
serviceDomains {
domain
}
}
serviceId
startCommand
}
}
}
}
}
}
}
query environments($projectId: String!) {
environments(projectId: $projectId) {
edges {
node {
id
name
serviceInstances {
edges {
node {
id
serviceId
domains {
serviceDomains {
domain
}
}
serviceId
startCommand
}
}
}
}
}
}
}
and I want to get the serviceName of the deployed service instance, is there any way to do this without making a subsequent query for each serviceId? which right now is
query environments($id: String!) {
service(id: $id) {
name
}
}
query environments($id: String!) {
service(id: $id) {
name
}
}
ideally ServiceInstance would have serviceName in addition to the currently existing serviceId
Solution:
```graphql query project($id: String!) { project(id: $id) { name services {...
Jump to solution
7 Replies
Percy
Percy6mo ago
Project ID: N/A
Faolain
Faolain6mo ago
N/A
Solution
Brody
Brody6mo ago
query project($id: String!) {
project(id: $id) {
name
services {
edges {
node {
id
name
}
}
}
environments {
edges {
node {
id
name
serviceInstances {
edges {
node {
serviceId
startCommand
domains {
serviceDomains {
domain
}
}
}
}
}
}
}
}
}
}
query project($id: String!) {
project(id: $id) {
name
services {
edges {
node {
id
name
}
}
}
environments {
edges {
node {
id
name
serviceInstances {
edges {
node {
serviceId
startCommand
domains {
serviceDomains {
domain
}
}
}
}
}
}
}
}
}
}
Brody
Brody6mo ago
then youd only have to join in code obviously like you said serviceInstances should have a name, but it doesn’t unfortunately, so this is the best i can think of
Faolain
Faolain6mo ago
hmm thanks brody interesting approach here, saves me from doing 3 queries and instead just need to join in the code instead, wasn't aware I could do a project query....would require a refactor of my entire railway action though since it relies on the environments query oof. Thank you Any way to make the request for adding name to the serviceInstance param?
Brody
Brody6mo ago
not until the new year since the team is on a partial vacation so i can really only involve the team member on call if theres an issue with the platform
Faolain
Faolain6mo ago
fair enough thank you