Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve cache.json generation implementation (reduce duplicated grapqhl calls in serialization workflow) #272

Open
1 of 5 tasks
thescientist13 opened this issue Jan 17, 2020 · 1 comment
Assignees
Labels
Data Data and GraphQL enhancement Improve something existing (e.g. no docs, new APIs, etc) Plugins Greenwood Plugins
Milestone

Comments

@thescientist13
Copy link
Member

thescientist13 commented Jan 17, 2020

Type of Change

  • New Feature Request
  • Documentation / Website
  • Improvement / Suggestion
  • Bug
  • Other (please clarify below)

Summary

Technical debt tracking for some of the issue rough and dirty technical design decisions made as part of implementing #115 .

Details

The way cache.json data gets written is a little convoluted since each request needs to be done twice before it can get written as cache.json as part of the build / serialization lifecycle.

  1. Puppeteer renders a page
  2. Request gets made to GraphQL server
  3. GraphQL intercepts the request and calls createCache
  4. createCache then instantiates an instance of Apollo client and makes a call back to the GraphQL server
  5. The response of that is then written to disk

This seems cumbersome and will likely not scale well? Or just seems slow. It would be great if on the response handler of the GraphQL server could handle writing to disk, or at least avoiding the duplicate query call, which has required us to do this or else we will get stuck in an infinite loop.

if (req.query.q !== 'internal') {
  await createCache(req, context);
}

Ideally, we could use some form of memoization so duplicated queries for a specific route subset are not repeated, which would certainly help with performance. This kind of caching improvement (memoization) could / should also applies to client.js as well to avoid unnecessary fetch calls.

@thescientist13 thescientist13 added chore unit testing, maintenance, etc Data Data and GraphQL labels Jan 17, 2020
@thescientist13 thescientist13 self-assigned this Jan 17, 2020
@thescientist13 thescientist13 changed the title improve cache.json generation implementation (reduce duplicated grapqhl calls to serialization workflow for improve cache.json generation implementation (reduce duplicated grapqhl calls in serialization workflow) Jan 17, 2020
@thescientist13
Copy link
Member Author

thescientist13 commented Jan 24, 2020

Note sure if using ssrMode would be of any help?

Also, maybe we could backfill the remaining properties of a response from calling client.query?

@thescientist13 thescientist13 removed this from TODO in 4 - Data Sources Mar 16, 2020
@thescientist13 thescientist13 added enhancement Improve something existing (e.g. no docs, new APIs, etc) and removed chore unit testing, maintenance, etc labels Mar 15, 2022
@thescientist13 thescientist13 added the Plugins Greenwood Plugins label Nov 4, 2023
@thescientist13 thescientist13 added this to the 1.x milestone Nov 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Data Data and GraphQL enhancement Improve something existing (e.g. no docs, new APIs, etc) Plugins Greenwood Plugins
Projects
None yet
Development

No branches or pull requests

1 participant