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

Performance improvements #158

Closed
3 tasks done
mike-marcacci opened this issue Mar 15, 2020 · 1 comment
Closed
3 tasks done

Performance improvements #158

mike-marcacci opened this issue Mar 15, 2020 · 1 comment

Comments

@mike-marcacci
Copy link
Member

mike-marcacci commented Mar 15, 2020

This is a general issue to track improvements, for which there are many opportunities. The code was kept simple and flexible during the early design, leaving the following opportunities:

  • Use the "data loader" pattern to batch and memoize entity calls within the same request
  • Use parameterized scopes to query the database within an authorization's context
  • Translate filters and pagination to SQL and execute on the database
@mike-marcacci
Copy link
Member Author

This issue has been split out into:

mike-marcacci added a commit that referenced this issue Aug 14, 2020
This addresses #158 by using the dataloader pattern to batch and memoize entity calls within the same request.

The design followed here introduces the concept of an "execution context" or Executor. An Executor instance is unique to the request, and is to be used as a key to WeakMap caches of entities.

Special care must be taken to avoid reusing stale data after a mutation. Accordingly, the Executor instance is replaced in the broader context object by each mutation. Because GraphQL guarantees that mutations are run serially, we don't have to worry about race conditions here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant