Expected Iterable, but did not find one for field “Query.launches”

Expected Iterable, but did not find one for field “Query.launches”


0

Schema

    type Query {
      launches: [Launch]
    }
    
    type Launch {
      id: String!
      mission_name: String
    }
    

Interface

    export interface launch {
      launches: Launch[];
    }
    
    export interface Launch {
      id: string;
      mission_name: string;
    }
    

Service file

  async getlaunches(): Promise<any> {
    console.log(JSON.stringify(this.launchEndpoint));
    this.logger.info('Demonstrate masking of logged data:');
    return await this.apiClient.post(this.launchEndpoint, {
      query: '{ launches { id, mission_name } }',
    });
  }

the launchEndpoint is this public URL : https://spacex-production.up.railway.app/

resolver file

  @Query('launches')
  async getLaunches(): Promise<any> {
    return this.apiclientService.getlaunches();
  }
    
    

Controller file

      @Get('launches')
      getlaunches(): any {
        return this.apiclientService.getlaunches();
      }
    
    

I have already tried couple of hours on this issue but no help, let me know if anyone know how to solve it.

Share

2

  • What is your apiclientService? Also, why are you returning a Promise<Observable<launch>>? You should probably convert the Observable to a Promise or only use Observables. There are use cases for when you need to mix the two, but this doesn't seem like one of them

    – Jay McDoniel

    45 mins ago

  • @JayMcDoniel Okay i have changes the Observable and now just using the promise. apiclientService is just the service class where, i have other functions as well to fetch for other services. When i am just call this public api with my query in the code it working well, and giving me the results but when i am using the same through the apollo sandbox its not able to give me desired result.

    – Krish909

    19 mins ago


Load 4 more related questions


Show fewer related questions

0

Reset to default



Browse other questions tagged

or ask your own question.

Leave a Reply

Your email address will not be published. Required fields are marked *