question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

server-side cache for a graphql datasource?

See original GitHub issue

Now we have an official REST datasource with cache enabled, while maybe I missed it in the doc but I am wondering how to do server-side cache for a graphQL datasource (like prisma)?

Theoretically it would be just the same logic with the caching strategy on apollo-client: we get some data from a graphql query, normalize it into a memory/redis cache, (and for what the client-side does’t have, we should config expiration time for them); when dealing with another query, just check the cache first (the logic has been already done in apollo-client).

So any recommended way to do this on the server-side? Is it possible to add a new data access layer between a graphql datasource (prisma) and our apollo-server (prisma <-> [an apollo-client like cache layer] <-> apollo-server) ?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
gotexiscommented, Mar 15, 2019

+1 for server-side caching

2reactions
beeplincommented, Sep 10, 2018

You would need to normalize the JSON into resources & types to increase cache hits,

Apollo-client is just doing nearly the same thing: sending graphql requests, normalizing the returned JSON into __typename:id key-value cache. Is it feasible to just use apollo-client with a redis cache to achieve this on the server-side?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Server-side caching - Apollo GraphQL Docs
When Apollo Server resolves an operation, it calculates the result's correct cache behavior based on the most restrictive settings among the result's fields ......
Read more >
GraphQL Caching on the Server for existing APIs
GraphQL Clients cache data with an in-memory cache. Control the number of times a resource should be considered fresh with response headers like...
Read more >
Caching in GraphQL: How to prevent excessive and ...
Now, caching in GraphQL can be done server-side. This means that the GraphQL server can be configured to fetch the response from its...
Read more >
Apollo Server - Confusion about cache/datasource options
While both of these caches reduce the time it takes to process your GraphQL response (fetching from cache is noticeably faster than from...
Read more >
Caching and compression - AWS AppSync
Caching behavior · None. No server-side caching. · Full request caching. If the data is not in the cache, it is retrieved from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found