9

In our GraphQL api (Apollo-Server) we would like to add a new dataSource which accesses GitHub's GraphQL api. We are looking to consume this data. It appears that using apollo-datasource-rest` is a good approach to do this. It's an established, still maintained module which provides caching, access to context and other dataSource benefits. It's also managed by the Apollo team. We want to verify that this is a good approach for making requests to other GraphQL APIs.

Other options are:

  • Roll your own datasource, which doesn't seem necessary or with apparent benefits
  • Build out a datasource using @apollo/client
  • There is a module, apollo-datasource-graphql, which appears fits this perfectly, though it has not been updated in two years and appears it may be unfinished with tests and request caching not complete.

Is using apollo-datasource-rest a good practice for accessing other GraphQL APIs as a dataSource in a GraphQL server service?

Is there a better, more established approach for doing this?

6
  • Any leads found ??Even I am confused if to use a rest data source for graphql api? Commented Jun 27, 2021 at 11:01
  • 2
    Yes, the Apollo rest data source library worked really well for us to make GraphQL calls from our api. Commented Jun 27, 2021 at 22:46
  • @Brettski can you please demonstrate how to call GraphQL API via apollo-rest-data-source? Commented Feb 12, 2022 at 13:23
  • @LaravelCoder Yes I can demonstrate it, though I am not sure where the best pace to do that. Our code is opensource and I would reference back to that with examples. This question here doesn't feel like the correct place. Commented Feb 12, 2022 at 20:26
  • @Brettski it could be very helpful if you share your source code or the links to the examples you referring to. Thank you Commented Feb 13, 2022 at 1:56

1 Answer 1

1

We are having the same concern since our backend needs to consume, as a client, a graphql api. The REST interface approach is expecting http GET queries to be cacheable, but not verbs like POST, PUT, DELETE... My understanding of GraphQL is that if you are only using http POST as a communication pattern this is going to prevent apollo-datasource-rest to handle caching for your queries and then it may not be the appropriate lib.

Other approaches to consider:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.