Questions tagged [apollo-datasource-rest]

9 questions
3
votes
3 answers

RESTDataSource - How to know if response comes from get request or cache

I need to get some data from a REST API in my GraphQL API. For that I'm extending RESTDataSource from apollo-datasource-rest. From what I understood, RESTDataSource caches automatically requests but I'd like to verify if it is indeed cached. Is…
mgse
  • 31
  • 1
2
votes
2 answers

How to invalidate cache in Apollo Server RESTDataSource

Using the simple "Movies API" example from the documentation. I added a ttl to the getMovie function, so that the result is cached for 10 minutes. How can I invalidate the cache in the updateMovie function? const { RESTDataSource } =…
Ropez
  • 3,485
  • 3
  • 28
  • 30
1
vote
1 answer

How to use multiple REST API endpoints (baseURLs) in apollo-datasource-rest?

I'm building a single GraphQL endpoint that has underlying REST services being called from different end points. I was able to execute Query successfully, but for mutation I refer a separate endpoint. How can I incorporate this in my code? export…
Min Yoongi
  • 396
  • 5
  • 16
1
vote
0 answers

how to download a pdf file in NodeJS with Apollo datasource rest

I try to call a rest api which returns a file response with Content-Type: application/pdf and Content-Encoding: gzip How do I download this file and can open from local drive? I use following code: import { RequestOptions, RESTDataSource } from…
Krunal Shah
  • 141
  • 4
1
vote
1 answer

Is it valid to return null from a didReceiveResponse callback?

I have a didReceiveResponse callback on a class that extends RESTDataSource in which I return null if the response status is 404. Because of the typing of RESTDataSource.didReceiveResponse it appears that this is invalid. async…
0
votes
1 answer

What is the correct way to add custom headers when calling REST-API from GraphQL Apollo-Server?

I tried to using below code, but it is failing to reach api with exception. class CountriesAPI extends RESTDataSource { constructor() { super(); this.baseURL = "http://localhost:9321"; } // this is the area i want to add custom headers…
Tat
  • 19
  • 1
  • 4
0
votes
2 answers

How to use client certificate in @apollo/datasource-rest

I am using subclass of @apollo/datasource-rest for fetching data from REST API's in my project. I need to add a client certificate in every request in made in my subclass. I know that It is possible to add certificate in the https https.Agent and it…
J.R
  • 2,113
  • 19
  • 21
0
votes
1 answer

Apollo REST Data Source and Imgur API - Keep getting 400 Bad Request using form data

I am trying to implement apollo-datasource-rest to handle image uploading by URL via Imgur's API (documentation here: https://apidocs.imgur.com/) I initially was getting a 400 error which read We don't support that file type!, and determined that it…
0
votes
1 answer

"Can't invoke class without new" and "Can't redeclare blocked-scoped variable" happening at the same time

I started having an error while trying to use RESTDataSource: "Class constructor RESTDataSource cannot be invoked without 'new'" So I tried this solution and added "target": "es2016". I don't get the error anymore. But now I'm getting typescript…
medicengonzo
  • 479
  • 1
  • 7
  • 23