1

I have a setup where I run a query on the frontend through the router (Apollo Federation Gateway) to two separate services exposing GQL endpoints - serviceA has findItems and serviceB has parseName.

Now I want to run the following query in one go:

query findMyItemDescriptionNameAndParse {
  findItems(id: 1) {
    description {
      name
    }
  }
  parseName(input: $name) {
     parsedName {
        name
     }
  }
}

Can Apollo pass the variables internally or I just have to split the query into two for such case?

Thank you.

Roy
  • 7,811
  • 4
  • 24
  • 47
Stranger95
  • 123
  • 1
  • 9

1 Answers1

1

Short answer: no. You'd have to run the two queries in sequence. What's preferable however is to define a different query that returns both the name and parsedName that you're looking for. Even better would be to extend the description to include a parsedName field and just write a resolver for that then you'd never need to run sequential queries.

Michel Floyd
  • 18,793
  • 4
  • 24
  • 39