简体   繁体   中英

Apollo resolvers - await result from another resolver

I have a question. I am using apollo -GraphQL and i have issue which i cant seem to solver correctly. So i have type lie this:

    Price {
  PriceBefore {
    value
    
  }
  PriceAfter {
    value
  }
  PriceSave {
    value
  }
}

And i index.ts i have:

 PriceBefore: async (data: SomeData, source: any, { dataSources }: any, context: any) => {
return someCalculation:
}

PriceAfter : async (data: SomeData, source: any, { dataSources }: any, context: any) => {
return someCalculation:
}

PriceSave : async (data: SomeData, source: any, { dataSources }: any, context: any) => {
return someCalculation:
}

My problem is that i don't know how to wait with PriceAfter to PriceBefore is finished and how could i transfer result from PriceBefore to PriceAfter. Same thin with PriceSave who should wait for PriceBefore and Price After to end and get data from them.

Is that possible does anybody knows?

Thank in advance

So in your case its not really doable.

You will have to split it into 2 calls and handle that from client.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM