Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request establishes a robust example and end-to-end testing framework for entity caching in a GraphQL federation environment. It illustrates the complete flow from gateway configuration with an in-memory cache to the implementation of type-level and field-level caching directives within subgraph schemas, ensuring that data is efficiently served from the cache on subsequent requests. Highlights
Ignored Files
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces an end-to-end test suite for GraphQL response caching, demonstrating both type-level and field-level caching with specific TTLs. The changes include new e2e tests, gateway configuration with an in-memory LRU cache, and two subgraph services defining the @cacheControl directive. Feedback suggests refactoring duplicated test setup logic in entity-caching.e2e.ts using describe and beforeEach blocks, and extracting duplicated schema definitions (like CacheControlScope and @cacheControl directive) from products.ts and reviews.ts into a shared file to improve maintainability.
| const products = await service('products'); | ||
| const reviews = await service('reviews'); | ||
| const gw = await gateway({ | ||
| supergraph: { | ||
| with: 'apollo', | ||
| services: [products, reviews], | ||
| }, | ||
| }); |
There was a problem hiding this comment.
This setup logic is duplicated from the test above (lines 7-14). To improve maintainability and adhere to the DRY (Don't Repeat Yourself) principle, consider using a describe block to group related tests and a beforeEach hook for common setup. This will make the tests cleaner and easier to maintain.
| enum CacheControlScope { | ||
| PUBLIC | ||
| PRIVATE | ||
| } | ||
|
|
||
| directive @cacheControl( | ||
| maxAge: Int | ||
| scope: CacheControlScope | ||
| inheritMaxAge: Boolean | ||
| ) on FIELD_DEFINITION | OBJECT | INTERFACE | UNION |
There was a problem hiding this comment.
No description provided.