convoyinc / apollo-cache-hermes Goto Github PK
View Code? Open in Web Editor NEWA cache implementation for Apollo Client, tuned for performance
License: Other
A cache implementation for Apollo Client, tuned for performance
License: Other
See greenkeeperio/greenkeeper#506 and #116
Currently, we interpolate variables at each field that requests them - instead, we could do this once when building the dynamic edge map
Utilizing an interface
gives the type a name, which makes it easier to debug (and also allows for augmentation)
Probably:
Once we've found a query to be complete (either by reading it, or by writing it), we should be guaranteed that it will continue to be complete, unless nodes are explicitly removed (not garbage collected).
There's no need to walk results on every read.
Branch | Build failing ๐จ |
---|---|
Dependency | typescript-eslint-parser |
Current Version | 8.0.0 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
typescript-eslint-parser is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 7 commits.
5e9e7fa
8.0.1
5a96293
Build: changelog update for 8.0.1
0401ffc
Fix: Calculate typeArguments loc data correctly if empty (fixes #395) (#396)
a214f71
Chore: Add a way to test TSX specific issues (fixes #376) (#398)
9c71a62
Fix: add missing TSSymbolKeyword type (#385)
e10aab8
Chore: Refactor alignment tests, now on by default (#387)
9e17d0b
Chore: Minor cleanup, fix jQuery foundation copyright (#383)
See the full diff
There is a collection of frequently asked questions. If those donโt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot ๐ด
Branch | Build failing ๐จ |
---|---|
Dependency | @types/node |
Current Version | 8.0.46 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
@types/node is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
There is a collection of frequently asked questions. If those donโt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot ๐ด
Let's get closer to actual GraphQL nomenclature, and is pretty damn confusing. The cache currently uses query interchangeably with operation in a bunch of places.
Gotta support 'em!
There are several places where we are leaking, or are storing more than necessary, and will eventually need to perform some sort of GC:
Hey guys, I'm really curious to see how your store performs compared with the InMemoryStore, especially when making several mutations per second and stacking a few hundred or a couple thousand optimistic updates before resolving them. However, there's very little documentation for this package and not even really a readme that tells me how to use it, and what to expect. For example, can I just plug it in place of the InMemoryStore with the same arguments (dataIdFromObject, addTypename being the most important ones) and expect everything to work, including readFragment and writeFragment? Or are there certain things that are different, things that haven't been implemented yet, etc.?
Btw, I looked into the source code to figure things out, but I still couldn't get it to work in Typescript because of missing exports and compiler issues (skipLibCheck didn't help). Are you actually using the package you published or are you using a local version?
Needed for persistence!
Update: Much of this has been implemented. See this comment for remaining work.
We don't support But it shouldn't be too difficult to support, I think.... on Type {
queries currently.
Rough outline of the work:
InlineFragment
AST nodes. Most likely, they are added as another field node (but explicitly flagged as being a union field)null
s shouldn't be inserted)Potential challenges:
__typename
or schema introspection)Consider peppering the code with assertions that are removed from the packaged output, but are active during tests
Branch | Build failing ๐จ |
---|---|
Dependency | typescript |
Current Version | 2.5.3 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
typescript is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
For release notes, check out the release announcement
For new features, check out the What's new in TypeScript 2.6.
For breaking changes, check out the Breaking changes in TypeScript 2.6 page.
For API breaking changes, check out the API Breaking changes in TypeScript 2.6 page.
For the complete list of fixed issues, check out the issues fixed in TypeScript 2.6 RC and after TypeScript 2.6 RC.
Download:
Special thanks to all contributors to this release:
The new version differs by 1177 commits ahead by 1177, behind by 85.
477bdc7
Update LKG
6bc04a9
Use lowercased names for generated locale directories (#19581)
0f32f55
Make getCompletionEntryDetails and getCompletionEntrySymbol parameters non-optional (#19507) (#19592)
1359a93
Update LKG
a7e172b
Support multiple completions with the same name but different source module (#19455) (#19496)
c35e90e
Merge pull request #19484 from Microsoft/reloadScriptsWithoutProject
96c66a6
Add test case to verify reload works without open project
b16e6d4
Reload contents of file from disk irrespective of project presence and file already containing its own text
6489a75
Update LKG
1a1c672
Merge pull request #19445 from Microsoft/foundWhileSearchingNodeModules
4e56347
Set the files found during node_modules search correctly when reusing existing program structure
aaaa280
Add the test case that fails and reports error for files not in root directory in watch mode
3134111
Merge pull request #19434 from Microsoft/port-master-10-23
a362bbf
Fix lint error
02cc07c
For @types installing quickfix, only activate for implicit-any module (#19394) (#19429)
There are 250 commits in total.
See the full diff
There is a collection of frequently asked questions. If those donโt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot ๐ด
Fix the bugs that were introduced in the code removed by #127
With TypeScript, type checker helps catching lots of mistake. However, when using using Hermes in JS codebase, I think it will be valuable to provide some runtime check for correct type for cache config.
One possible option to do so (https://github.com/rbuckton/reflect-metadata)
Rename apollo/Transaction -> DataProxy
for consistency
Update method of ApolloTrasaction
class to have similar API as DataProxy
The workspaces are great, except they aren't preserved for reruns :(
We probably need to work with that project to figure out the right interface to expose to the dev tools.
Need to support cache redirects.
Motivation is to support queries like:
query getAUser($id: ID!) {
user(id: $id) { ... }
}
and return the entity with that id, no matter where it was retrieved from
Branch | Build failing ๐จ |
---|---|
Dependency | apollo-utilities |
Current Version | 1.0.1 |
Type | dependency |
This version is covered by your current version range and after updating it in your project the build failed.
apollo-utilities is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.
There is a collection of frequently asked questions. If those donโt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot ๐ด
Currently, we walk the payload when merges values into the cache. This leads to ambiguity and hacky situations where we can't know whether a value should be placed directly in the cache, or walked - particularly for fields that contain complex objects
Branch | Build failing ๐จ |
---|---|
Dependency | @types/lodash |
Current Version | 4.14.78 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
@types/lodash is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
There is a collection of frequently asked questions. If those donโt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot ๐ด
Once the API solidifies, let's test the crap out of it.
From doing rewrite work, I realize that it is quite hard to understand the test because in a file there can be multiple describe which make it a bit hard to parse and understand. I propose that we should have one describe per file. The downside is that running take will take a bit longer as there are more initialization process to do
operations/write
operations/read
Branch | Build failing ๐จ |
---|---|
Dependency | eslint-plugin-jest |
Current Version | 21.2.0 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
eslint-plugin-jest is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
There is a collection of frequently asked questions. If those donโt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot ๐ด
They're getting pretty hard to categorize/find
Branch | Build failing ๐จ |
---|---|
Dependency | @types/chai |
Current Version | 4.0.5 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
@types/chai is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
There is a collection of frequently asked questions. If those donโt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot ๐ด
Branch | Build failing ๐จ |
---|---|
Dependency | eslint |
Current Version | 4.6.1 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As eslint is โonlyโ a devDependency of this project it might not break production or downstream projects, but โonlyโ your build or test tools โ preventing new deploys or publishes.
I recommend you give this issue a high priority. Iโm sure you can resolve this ๐ช
node.parent
is already set (fixes #9122) (#9283) (Teddy Katz)return
(fixes #9285) (#9296) (Teddy Katz)npm run perf
description (#9274) (Teddy Katz)The new version differs by 55 commits.
439e8e6
4.7.0
2ec62f9
Build: changelog update for 4.7.0
787b78b
Upgrade: Espree v3.5.1 (fixes #9153) (#9314)
1488b51
Update: run rules after node.parent
is already set (fixes #9122) (#9283)
4431d68
Docs: fix wrong config in max-len example. (#9309)
9d1df92
Chore: Revert "avoid handling Rules instances in config-validator" (#9295)
7d24dde
Docs: Fix code snippet to refer to the correct option (#9313)
12388d4
๏ฟฝChore: rewrite parseListConfig for a small perf gain. (#9300)
ce1f084
Update: fix MemberExpression handling in no-extra-parens (fixes #9156)
0c720a3
Update: allow autofixing when using processors (fixes #7510) (#9090)
838df76
Chore: upgrade deps. (#9289)
f12def6
Update: indent flatTernary option to handle return
(fixes #9285) (#9296)
e220687
Fix: remove autofix for var undef inits (fixes #9231) (#9288)
002e199
Docs: fix no-restricted-globals wrong config. (#9305)
fcfe91a
Docs: fix wrong config in id-length example. (#9303)
There are 55 commits in total.
See the full diff
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot ๐ด
Summary: It is comment in the code. But we should investigating whether to just use native ES6 map instead of Object.create(null)
Branch | Build failing ๐จ |
---|---|
Dependency | eslint |
Current Version | 4.11.0 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
sort-vars
(#9496) (Trevin Hofmann)beforeStatementContinuationChars
to semi (fixes #9521) (#9594) (Toru Nagashima)globals
to 11.0.1 (fixes #9614) (#9632) (Toru Nagashima)The new version differs by 15 commits.
f4a65c6
4.12.0
1cd1627
Build: changelog update for 4.12.0
76dab18
Upgrade: doctrine@^2.0.2 (#9656)
28c9c8e
New: add a Linter#defineParser function (#9321)
5619910
Update: Add autofix for sort-vars
(#9496)
71eedbf
Update: add beforeStatementContinuationChars
to semi (fixes #9521) (#9594)
4118f14
New: Adds implicit-arrow-linebreak rule (refs #9510) (#9629)
208fb0f
Fix: Use XML 1.1 on XML formatters (fixes #9607) (#9608)
6e04f14
Upgrade: globals
to 11.0.1 (fixes #9614) (#9632)
e13d439
Fix: space-in-parens crash (#9655)
92171cc
Docs: Updating migration guide for single-line disable (#9385)
f39ffe7
Docs: remove extra punctuation from readme (#9640)
a015234
Fix: prefer-destructuring false positive on "super" (fixes #9625) (#9626)
0cf081e
Update: add importNames option to no-restricted-imports (#9506)
332c214
Docs: Add @platinumazure to TSC (#9618)
See the full diff
There is a collection of frequently asked questions. If those donโt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot ๐ด
Is apollo-cache-hermes
(and Hermes in general) really the package name we want? Surely there's a better name to go with!
This will make us more consistent with Apollo's interfaces, and hopefully reduce some confusion.
Today, when overlaying parameterized edges on top of a query, we generate new objects every time. They should be generated only when their (transitive) values change.
Can we pre-calculate them per query on write? It might require pre-processing the user's schema?
Branch | Build failing ๐จ |
---|---|
Dependency | eslint-plugin-typescript |
Current Version | 0.8.0 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
eslint-plugin-typescript is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 7 commits.
12220cc
Chore: Update prettier and pin the version (#94)
3284af4
Fix: Mark call expression type parameters as used (#89)
29bd53c
Fix: Mark qualified name type annotations as used (#88)
5e3999d
Fix: Destructured param type annotation not marked used (fixes #82) (#84)
2b197fd
Fix: Handles type spacing on TSParenthesizedType expressions (fixes #79) (#80)
45cd23e
Fix: no-triple-slash-reference (fixes #75)
485254b
Chore: Publish version 0.8.0 to npm
See the full diff
There is a collection of frequently asked questions. If those donโt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot ๐ด
I'm trying Apollo 2.0, and didn't see much performance improvements using the default in-memory cache, in some cases it's actually worse than the Redux based version. I'm testing with pages that have 1000+ objects (or nodes, in Hermes terminology), so I decided to try with Hermes, as it seems to be fastest that any GraphQL cache out there.
When testing 0.3.0-alpha
(and apollo-client
2.0.0-beta.4
) I get the following error:
TypeError: this.dataStore.getCache(...).transformDocument is not a function
at QueryManager.fetchQuery
at QueryManager.startQuery
at ObservableQuery.setUpQuery
at ObservableQuery.onSubscribe
at new Subscription
at ObservableQuery.Observable.subscribe
at Expansion._this.subscribeToQuery
at Expansion._this.handleQuery
at Expansion._this.updateWrapperQuery
This is how I'm creating the client. Note I'm using dataIdFromObject
and an auth link:
...
import { Cache as HermesCache } from 'apollo-cache-hermes';
export const createApolloClient = ({
databaseId,
previewKey,
uri = `/api/v1/databases/${databaseId}/apollo?preview=${previewKey}`,
ssrMode = false,
}) => {
...
return new ApolloClient({
link,
cache: new HermesCache({
dataIdFromObject: object => object.id
}),
ssrMode,
});
};
Is there anything else I should do to make the Hermes cache work?
Add an option for entity Transformers to support things like domain object classes
See #49
There are a lot of duplicate code across test files. We should consolidate them and write helper functions/classes etc. to do all test setup work.
operation/write/basic
operation/write/cyclicReferences
operation/write/editValues
operation/write/fieldAlias
operation/write/fragment
operation/write/freezing
operation/write/minimalUpdates
operation/write/orphaning
operation/write/parameterizedFields
operation/write/mergeReferencesPayload
operation/read
This works will be much easier after #136
Branch | Build failing ๐จ |
---|---|
Dependency | jest-junit |
Current Version | 3.2.1 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
jest-junit is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 2 commits.
c35c423
Add unit test for testSuite->tests attribute existence and correctness
e78b16f
Fix tests attribute in testSuite and bump to 3.3.0
See the full diff
There is a collection of frequently asked questions. If those donโt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot ๐ด
Walking ever-expanding lists from fetchMore
causes ever-worse performance. Can we be smarter about pagination? (without changing Apollo's interface? Or do we need to propose something else?)
Today, Apollo's in-memory cache generates an id from the relative path to it (containerId + path).
Hermes similarly merges values. However, that approach leads to ambiguous state in the cache specifically with arrays.
For example, imagine the following updates to the cache:
{
stuff: [
{ foo: 1, bar: 1 },
{ foo: 2, bar: 2 }
]
}
And then say that the server's view resorted stuff
, and added a new entry; and then we select only bar
fields:
{
stuff: [
{ bar: 2 },
{ bar: 1 },
{ bar: 3 }
]
}
At this point, the cache will have merged state into:
{
stuff: [
{ foo: 1, bar: 2 },
{ foo: 2, bar: 1 },
{ bar: 3 }
]
}
Which is incorrect from the server's perspective.
Branch | Build failing ๐จ |
---|---|
Dependency | apollo-cache |
Current Version | 1.0.0 |
Type | dependency |
This version is covered by your current version range and after updating it in your project the build failed.
apollo-cache is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.
There is a collection of frequently asked questions. If those donโt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot ๐ด
This is how I am currently using apollo-client
v2:
// @flow
import {
ApolloClient
} from 'apollo-client';
import {
HttpLink
} from 'apollo-link-http';
import InMemoryCache, {
IntrospectionFragmentMatcher
} from 'apollo-cache-inmemory';
const fragmentMatcher = new IntrospectionFragmentMatcher({
introspectionQueryResultData: {
// eslint-disable-next-line id-match
__schema: {
types: [
{
kind: 'INTERFACE',
name: 'Paragraph',
possibleTypes: [
{
name: 'TextParagraph'
},
{
name: 'ImageParagraph'
}
]
},
{
kind: 'INTERFACE',
name: 'Markup',
possibleTypes: [
{
name: 'DecorationMarkup'
},
{
name: 'LinkMarkup'
}
]
}
]
}
}
});
const apolloClient = new ApolloClient({
cache: new InMemoryCache({
fragmentMatcher: fragmentMatcher.match
}),
link: new HttpLink({
credentials: 'include',
uri: '/api'
})
});
export default apolloClient;
I have tried migrating to apollo-cache-hermes
, but I could not find the equivalent of IntrospectionFragmentMatcher
in the code base.
Today we cache them just the same as ROOT_QUERY nodes; but there's no good reason for doing so. It also generally leaks large amounts of posted data (via serialized variables) into the cache
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.