houdini 2.0.0-next.9 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/adapter/index.d.ts +2 -2
- package/build/adapter/index.js +6 -0
- package/build/cmd/generate.d.ts +5 -0
- package/build/cmd/generate.js +77 -0
- package/build/cmd/index.js +32 -0
- package/build/cmd/init.js +565 -0
- package/build/cmd/pullSchema.js +26 -0
- package/build/lib/ast.js +71 -0
- package/build/lib/codegen.d.ts +57 -0
- package/build/lib/codegen.js +617 -0
- package/build/lib/config.d.ts +240 -177
- package/build/lib/config.js +143 -0
- package/build/lib/constants.js +14 -0
- package/build/lib/database.d.ts +7 -0
- package/build/lib/database.js +624 -0
- package/build/lib/db.d.ts +13 -0
- package/build/lib/db.js +135 -0
- package/build/lib/deepMerge.js +23 -0
- package/build/lib/error.d.ts +16 -0
- package/build/lib/error.js +115 -0
- package/build/lib/fs.d.ts +9 -11
- package/build/lib/fs.js +245 -0
- package/build/lib/graphql.d.ts +5 -32
- package/build/lib/graphql.js +36 -0
- package/build/lib/imports.d.ts +29 -14
- package/build/lib/imports.js +66 -0
- package/build/lib/index.d.ts +17 -24
- package/build/lib/index.js +21 -0
- package/build/lib/logger.d.ts +12 -0
- package/build/lib/logger.js +45 -0
- package/build/lib/parse.d.ts +1 -2
- package/build/lib/parse.js +32 -0
- package/build/lib/path.d.ts +0 -1
- package/build/lib/path.js +44 -0
- package/build/lib/pipeline.d.ts +1 -1
- package/build/lib/pipeline.js +8 -0
- package/build/lib/plugins.d.ts +4 -0
- package/build/lib/plugins.js +88 -0
- package/build/lib/project.d.ts +19 -0
- package/build/lib/project.js +296 -0
- package/build/lib/schema.d.ts +1 -0
- package/build/lib/schema.js +61 -0
- package/build/lib/sleep.d.ts +1 -0
- package/build/lib/sleep.js +8 -0
- package/build/lib/types.d.ts +92 -303
- package/build/lib/types.js +37 -0
- package/build/lib/walk.d.ts +11 -6
- package/build/lib/walk.js +138 -0
- package/build/node/index.d.ts +44 -0
- package/build/node/index.js +402 -0
- package/build/oauth/index.d.ts +41 -0
- package/build/oauth/index.js +108 -0
- package/build/package.json +212 -0
- package/build/router/auth-token.d.ts +29 -0
- package/build/router/auth-token.js +168 -0
- package/build/{lib/router → router}/conventions.d.ts +10 -1
- package/build/router/conventions.js +165 -0
- package/build/{runtime-esm/router → router}/cookies.js +21 -21
- package/build/{runtime-esm/router → router}/jwt.js +8 -6
- package/build/{lib/router → router}/manifest.d.ts +2 -2
- package/build/router/manifest.js +279 -0
- package/build/{runtime/router → router}/match.d.ts +10 -10
- package/build/router/match.js +219 -0
- package/build/router/server.d.ts +57 -0
- package/build/router/server.js +500 -0
- package/build/{runtime/router → router}/session.d.ts +8 -3
- package/build/router/session.js +338 -0
- package/build/router/types.d.ts +44 -0
- package/build/runtime/cache/benchmarks/cache.bench.d.ts +1 -0
- package/build/runtime/cache/benchmarks/cache.bench.js +943 -0
- package/build/runtime/cache/gc.d.ts +2 -1
- package/build/{runtime-esm → runtime}/cache/gc.js +4 -1
- package/build/runtime/cache/index.d.ts +173 -3
- package/build/{runtime-esm/cache/cache.js → runtime/cache/index.js} +197 -70
- package/build/runtime/cache/lists.d.ts +9 -4
- package/build/{runtime-esm → runtime}/cache/lists.js +116 -27
- package/build/runtime/cache/staleManager.d.ts +2 -1
- package/build/{runtime-esm → runtime}/cache/staleManager.js +6 -2
- package/build/runtime/cache/storage.d.ts +5 -2
- package/build/{runtime-esm → runtime}/cache/storage.js +126 -54
- package/build/{runtime-esm → runtime}/cache/stuff.js +4 -3
- package/build/runtime/cache/subscription.d.ts +23 -9
- package/build/{runtime-esm → runtime}/cache/subscription.js +103 -65
- package/build/runtime/{client/index.d.ts → client.d.ts} +15 -22
- package/build/runtime/client.js +86 -0
- package/build/runtime/coerce.d.ts +4 -0
- package/build/runtime/coerce.js +31 -0
- package/build/runtime/config.d.ts +20 -0
- package/build/runtime/config.js +88 -0
- package/build/runtime/{lib/constants.d.ts → constants.d.ts} +1 -1
- package/build/runtime/{client/documentStore.d.ts → documentStore.d.ts} +18 -11
- package/build/{runtime-esm/client → runtime}/documentStore.js +53 -56
- package/build/runtime/endpoint.d.ts +14 -0
- package/build/runtime/endpoint.js +29 -0
- package/build/{runtime-cjs/lib → runtime}/flatten.d.ts +1 -1
- package/build/runtime/formData.d.ts +24 -0
- package/build/runtime/formData.js +93 -0
- package/build/runtime/index.d.ts +16 -8
- package/build/runtime/index.js +54 -0
- package/build/{runtime-cjs/lib → runtime}/key.d.ts +1 -1
- package/build/{runtime-esm/lib → runtime}/key.js +4 -4
- package/build/{runtime-esm/lib → runtime}/log.js +3 -3
- package/build/runtime/multipart.d.ts +8 -0
- package/build/runtime/multipart.js +49 -0
- package/build/{runtime-cjs/lib → runtime}/pageInfo.d.ts +3 -3
- package/build/{runtime-esm/lib → runtime}/pageInfo.js +2 -2
- package/build/{runtime-cjs/lib → runtime}/pagination.d.ts +12 -8
- package/build/{runtime-esm/lib → runtime}/pagination.js +157 -21
- package/build/{runtime-cjs/lib → runtime}/scalars.d.ts +6 -6
- package/build/{runtime-esm/lib → runtime}/scalars.js +10 -43
- package/build/{runtime-cjs/lib → runtime}/selection.d.ts +1 -1
- package/build/{runtime-esm/lib → runtime}/selection.js +17 -2
- package/build/runtime/{lib/store.d.ts → store.d.ts} +1 -1
- package/build/{runtime-esm/lib → runtime}/store.js +2 -3
- package/build/runtime/{lib/types.d.ts → types.d.ts} +102 -101
- package/build/{runtime-esm/lib → runtime}/types.js +9 -14
- package/build/test/index.d.ts +6 -25
- package/build/test/index.js +329 -0
- package/build/test/package.json +1 -0
- package/build/vite/hmr.d.ts +26 -3
- package/build/vite/hmr.js +431 -0
- package/build/vite/houdini.d.ts +4 -10
- package/build/vite/houdini.js +134 -0
- package/build/vite/index.d.ts +13 -7
- package/build/vite/index.js +104 -0
- package/build/vite/package.json +1 -0
- package/build/vite/schema.d.ts +5 -3
- package/build/vite/schema.js +193 -0
- package/package.json +148 -57
- package/build/adapter-cjs/index.js +0 -33
- package/build/adapter-cjs/package.json +0 -1
- package/build/adapter-esm/index.js +0 -9
- package/build/cmd-cjs/index.js +0 -89299
- package/build/cmd-cjs/package.json +0 -1
- package/build/cmd-esm/index.js +0 -89303
- package/build/codegen/generators/artifacts/fieldKey.d.ts +0 -3
- package/build/codegen/generators/artifacts/index.d.ts +0 -17
- package/build/codegen/generators/artifacts/indexFile.d.ts +0 -2
- package/build/codegen/generators/artifacts/inputs.d.ts +0 -4
- package/build/codegen/generators/artifacts/operations.d.ts +0 -11
- package/build/codegen/generators/artifacts/selection.d.ts +0 -20
- package/build/codegen/generators/artifacts/utils.d.ts +0 -8
- package/build/codegen/generators/comments/jsdoc.d.ts +0 -2
- package/build/codegen/generators/definitions/enums.d.ts +0 -2
- package/build/codegen/generators/definitions/index.d.ts +0 -2
- package/build/codegen/generators/index.d.ts +0 -6
- package/build/codegen/generators/indexFile/index.d.ts +0 -2
- package/build/codegen/generators/persistedQueries/index.d.ts +0 -2
- package/build/codegen/generators/runtime/graphqlFunction.d.ts +0 -2
- package/build/codegen/generators/runtime/index.d.ts +0 -3
- package/build/codegen/generators/runtime/injectPlugins.d.ts +0 -7
- package/build/codegen/generators/runtime/pluginIndex.d.ts +0 -5
- package/build/codegen/generators/runtime/pluginRuntime.d.ts +0 -15
- package/build/codegen/generators/runtime/runtimeConfig.d.ts +0 -7
- package/build/codegen/generators/typescript/addReferencedInputTypes.d.ts +0 -4
- package/build/codegen/generators/typescript/documentTypes.d.ts +0 -2
- package/build/codegen/generators/typescript/imperativeTypeDef.d.ts +0 -2
- package/build/codegen/generators/typescript/index.d.ts +0 -2
- package/build/codegen/generators/typescript/inlineType.d.ts +0 -29
- package/build/codegen/generators/typescript/loadingState.d.ts +0 -8
- package/build/codegen/index.d.ts +0 -8
- package/build/codegen/transforms/addFields.d.ts +0 -2
- package/build/codegen/transforms/collectDefinitions.d.ts +0 -9
- package/build/codegen/transforms/componentFields.d.ts +0 -8
- package/build/codegen/transforms/fragmentVariables.d.ts +0 -17
- package/build/codegen/transforms/index.d.ts +0 -9
- package/build/codegen/transforms/list.d.ts +0 -9
- package/build/codegen/transforms/paginate.d.ts +0 -4
- package/build/codegen/transforms/runtimeScalars.d.ts +0 -2
- package/build/codegen/transforms/schema.d.ts +0 -2
- package/build/codegen/transforms/typename.d.ts +0 -2
- package/build/codegen/utils/commonjs.d.ts +0 -5
- package/build/codegen/utils/flattenSelections.d.ts +0 -11
- package/build/codegen/utils/index.d.ts +0 -4
- package/build/codegen/utils/moduleExport.d.ts +0 -4
- package/build/codegen/utils/murmur.d.ts +0 -9
- package/build/codegen/utils/objectIdentificationSelection.d.ts +0 -3
- package/build/codegen/utils/stripLoc.d.ts +0 -3
- package/build/codegen/validators/componentFields.d.ts +0 -2
- package/build/codegen/validators/index.d.ts +0 -5
- package/build/codegen/validators/noIDAlias.d.ts +0 -2
- package/build/codegen/validators/plugins.d.ts +0 -3
- package/build/codegen/validators/typeCheck.d.ts +0 -5
- package/build/codegen/validators/uniqueNames.d.ts +0 -2
- package/build/codegen-cjs/index.js +0 -74656
- package/build/codegen-cjs/package.json +0 -1
- package/build/codegen-esm/index.js +0 -74655
- package/build/lib/cleanupFiles.d.ts +0 -1
- package/build/lib/detectTools.d.ts +0 -16
- package/build/lib/introspection.d.ts +0 -3
- package/build/lib/plugin.d.ts +0 -2
- package/build/lib/router/index.d.ts +0 -9
- package/build/lib/router/server.d.ts +0 -7
- package/build/lib/router/types.d.ts +0 -23
- package/build/lib/typescript.d.ts +0 -20
- package/build/lib/watchAndRun.d.ts +0 -61
- package/build/lib-cjs/index.js +0 -79739
- package/build/lib-cjs/package.json +0 -1
- package/build/lib-esm/index.js +0 -79648
- package/build/runtime/cache/cache.d.ts +0 -169
- package/build/runtime/client/plugins/cache.d.ts +0 -9
- package/build/runtime/client/plugins/fetch.d.ts +0 -38
- package/build/runtime/client/plugins/fetchParams.d.ts +0 -9
- package/build/runtime/client/plugins/fragment.d.ts +0 -2
- package/build/runtime/client/plugins/index.d.ts +0 -9
- package/build/runtime/client/plugins/injectedPlugins.d.ts +0 -4
- package/build/runtime/client/plugins/mutation.d.ts +0 -2
- package/build/runtime/client/plugins/optimisticKeys.d.ts +0 -7
- package/build/runtime/client/plugins/query.d.ts +0 -2
- package/build/runtime/client/plugins/subscription.d.ts +0 -20
- package/build/runtime/client/plugins/test.d.ts +0 -15
- package/build/runtime/client/plugins/throwOnError.d.ts +0 -8
- package/build/runtime/client/utils/documentPlugins.d.ts +0 -3
- package/build/runtime/client/utils/index.d.ts +0 -1
- package/build/runtime/generated.d.ts +0 -5
- package/build/runtime/imports/config.d.ts +0 -3
- package/build/runtime/imports/pluginConfig.d.ts +0 -3
- package/build/runtime/lib/config.d.ts +0 -216
- package/build/runtime/lib/deepEquals.d.ts +0 -1
- package/build/runtime/lib/flatten.d.ts +0 -2
- package/build/runtime/lib/index.d.ts +0 -10
- package/build/runtime/lib/key.d.ts +0 -6
- package/build/runtime/lib/log.d.ts +0 -6
- package/build/runtime/lib/lru.d.ts +0 -52
- package/build/runtime/lib/pageInfo.d.ts +0 -7
- package/build/runtime/lib/pagination.d.ts +0 -27
- package/build/runtime/lib/scalars.d.ts +0 -14
- package/build/runtime/lib/selection.d.ts +0 -2
- package/build/runtime/public/cache.d.ts +0 -42
- package/build/runtime/public/index.d.ts +0 -1
- package/build/runtime/public/list.d.ts +0 -18
- package/build/runtime/public/record.d.ts +0 -40
- package/build/runtime/public/tests/test.d.ts +0 -156
- package/build/runtime/public/types.d.ts +0 -62
- package/build/runtime/router/cookies.d.ts +0 -41
- package/build/runtime/router/jwt.d.ts +0 -117
- package/build/runtime/router/server.d.ts +0 -24
- package/build/runtime/router/types.d.ts +0 -26
- package/build/runtime/server/index.d.ts +0 -17
- package/build/runtime-cjs/cache/cache.d.ts +0 -169
- package/build/runtime-cjs/cache/cache.js +0 -1077
- package/build/runtime-cjs/cache/constants.d.ts +0 -1
- package/build/runtime-cjs/cache/constants.js +0 -28
- package/build/runtime-cjs/cache/gc.d.ts +0 -10
- package/build/runtime-cjs/cache/gc.js +0 -74
- package/build/runtime-cjs/cache/index.d.ts +0 -3
- package/build/runtime-cjs/cache/index.js +0 -25
- package/build/runtime-cjs/cache/lists.d.ts +0 -89
- package/build/runtime-cjs/cache/lists.js +0 -467
- package/build/runtime-cjs/cache/staleManager.d.ts +0 -31
- package/build/runtime-cjs/cache/staleManager.js +0 -123
- package/build/runtime-cjs/cache/storage.d.ts +0 -110
- package/build/runtime-cjs/cache/storage.js +0 -451
- package/build/runtime-cjs/cache/stuff.d.ts +0 -2
- package/build/runtime-cjs/cache/stuff.js +0 -56
- package/build/runtime-cjs/cache/subscription.d.ts +0 -52
- package/build/runtime-cjs/cache/subscription.js +0 -349
- package/build/runtime-cjs/client/documentStore.d.ts +0 -107
- package/build/runtime-cjs/client/documentStore.js +0 -487
- package/build/runtime-cjs/client/index.d.ts +0 -50
- package/build/runtime-cjs/client/index.js +0 -162
- package/build/runtime-cjs/client/plugins/cache.d.ts +0 -9
- package/build/runtime-cjs/client/plugins/cache.js +0 -138
- package/build/runtime-cjs/client/plugins/fetch.d.ts +0 -38
- package/build/runtime-cjs/client/plugins/fetch.js +0 -210
- package/build/runtime-cjs/client/plugins/fetchParams.d.ts +0 -9
- package/build/runtime-cjs/client/plugins/fetchParams.js +0 -47
- package/build/runtime-cjs/client/plugins/fragment.d.ts +0 -2
- package/build/runtime-cjs/client/plugins/fragment.js +0 -77
- package/build/runtime-cjs/client/plugins/index.d.ts +0 -9
- package/build/runtime-cjs/client/plugins/index.js +0 -45
- package/build/runtime-cjs/client/plugins/injectedPlugins.d.ts +0 -4
- package/build/runtime-cjs/client/plugins/injectedPlugins.js +0 -25
- package/build/runtime-cjs/client/plugins/mutation.d.ts +0 -2
- package/build/runtime-cjs/client/plugins/mutation.js +0 -89
- package/build/runtime-cjs/client/plugins/optimisticKeys.d.ts +0 -7
- package/build/runtime-cjs/client/plugins/optimisticKeys.js +0 -324
- package/build/runtime-cjs/client/plugins/query.d.ts +0 -2
- package/build/runtime-cjs/client/plugins/query.js +0 -93
- package/build/runtime-cjs/client/plugins/subscription.d.ts +0 -20
- package/build/runtime-cjs/client/plugins/subscription.js +0 -114
- package/build/runtime-cjs/client/plugins/test.d.ts +0 -15
- package/build/runtime-cjs/client/plugins/test.js +0 -118
- package/build/runtime-cjs/client/plugins/throwOnError.d.ts +0 -8
- package/build/runtime-cjs/client/plugins/throwOnError.js +0 -47
- package/build/runtime-cjs/client/utils/documentPlugins.d.ts +0 -3
- package/build/runtime-cjs/client/utils/documentPlugins.js +0 -57
- package/build/runtime-cjs/client/utils/index.d.ts +0 -1
- package/build/runtime-cjs/client/utils/index.js +0 -22
- package/build/runtime-cjs/generated.d.ts +0 -5
- package/build/runtime-cjs/generated.js +0 -16
- package/build/runtime-cjs/imports/config.d.ts +0 -3
- package/build/runtime-cjs/imports/config.js +0 -24
- package/build/runtime-cjs/imports/pluginConfig.d.ts +0 -3
- package/build/runtime-cjs/imports/pluginConfig.js +0 -25
- package/build/runtime-cjs/index.d.ts +0 -8
- package/build/runtime-cjs/index.js +0 -61
- package/build/runtime-cjs/lib/config.d.ts +0 -216
- package/build/runtime-cjs/lib/config.js +0 -110
- package/build/runtime-cjs/lib/constants.d.ts +0 -6
- package/build/runtime-cjs/lib/constants.js +0 -38
- package/build/runtime-cjs/lib/deepEquals.js +0 -52
- package/build/runtime-cjs/lib/flatten.js +0 -41
- package/build/runtime-cjs/lib/index.d.ts +0 -10
- package/build/runtime-cjs/lib/index.js +0 -40
- package/build/runtime-cjs/lib/key.js +0 -41
- package/build/runtime-cjs/lib/log.js +0 -72
- package/build/runtime-cjs/lib/lru.js +0 -73
- package/build/runtime-cjs/lib/pageInfo.js +0 -79
- package/build/runtime-cjs/lib/pagination.js +0 -240
- package/build/runtime-cjs/lib/scalars.js +0 -147
- package/build/runtime-cjs/lib/selection.js +0 -66
- package/build/runtime-cjs/lib/store.d.ts +0 -19
- package/build/runtime-cjs/lib/store.js +0 -81
- package/build/runtime-cjs/lib/types.d.ts +0 -417
- package/build/runtime-cjs/lib/types.js +0 -104
- package/build/runtime-cjs/package.json +0 -1
- package/build/runtime-cjs/public/cache.d.ts +0 -42
- package/build/runtime-cjs/public/cache.js +0 -98
- package/build/runtime-cjs/public/index.d.ts +0 -1
- package/build/runtime-cjs/public/index.js +0 -28
- package/build/runtime-cjs/public/list.d.ts +0 -18
- package/build/runtime-cjs/public/list.js +0 -151
- package/build/runtime-cjs/public/record.d.ts +0 -40
- package/build/runtime-cjs/public/record.js +0 -94
- package/build/runtime-cjs/public/tests/test.d.ts +0 -156
- package/build/runtime-cjs/public/tests/test.js +0 -60
- package/build/runtime-cjs/public/types.d.ts +0 -62
- package/build/runtime-cjs/public/types.js +0 -16
- package/build/runtime-cjs/router/cookies.js +0 -168
- package/build/runtime-cjs/router/jwt.js +0 -168
- package/build/runtime-cjs/router/match.d.ts +0 -39
- package/build/runtime-cjs/router/match.js +0 -158
- package/build/runtime-cjs/router/server.d.ts +0 -24
- package/build/runtime-cjs/router/server.js +0 -117
- package/build/runtime-cjs/router/session.d.ts +0 -22
- package/build/runtime-cjs/router/session.js +0 -100
- package/build/runtime-cjs/router/types.d.ts +0 -26
- package/build/runtime-cjs/router/types.js +0 -16
- package/build/runtime-cjs/server/index.d.ts +0 -17
- package/build/runtime-cjs/server/index.js +0 -62
- package/build/runtime-esm/cache/cache.d.ts +0 -169
- package/build/runtime-esm/cache/constants.d.ts +0 -1
- package/build/runtime-esm/cache/gc.d.ts +0 -10
- package/build/runtime-esm/cache/index.d.ts +0 -3
- package/build/runtime-esm/cache/index.js +0 -5
- package/build/runtime-esm/cache/lists.d.ts +0 -89
- package/build/runtime-esm/cache/staleManager.d.ts +0 -31
- package/build/runtime-esm/cache/storage.d.ts +0 -110
- package/build/runtime-esm/cache/stuff.d.ts +0 -2
- package/build/runtime-esm/cache/subscription.d.ts +0 -52
- package/build/runtime-esm/client/documentStore.d.ts +0 -107
- package/build/runtime-esm/client/index.d.ts +0 -50
- package/build/runtime-esm/client/index.js +0 -130
- package/build/runtime-esm/client/plugins/cache.d.ts +0 -9
- package/build/runtime-esm/client/plugins/cache.js +0 -104
- package/build/runtime-esm/client/plugins/fetch.d.ts +0 -38
- package/build/runtime-esm/client/plugins/fetch.js +0 -184
- package/build/runtime-esm/client/plugins/fetchParams.d.ts +0 -9
- package/build/runtime-esm/client/plugins/fetchParams.js +0 -23
- package/build/runtime-esm/client/plugins/fragment.d.ts +0 -2
- package/build/runtime-esm/client/plugins/fragment.js +0 -53
- package/build/runtime-esm/client/plugins/index.d.ts +0 -9
- package/build/runtime-esm/client/plugins/index.js +0 -12
- package/build/runtime-esm/client/plugins/injectedPlugins.d.ts +0 -4
- package/build/runtime-esm/client/plugins/injectedPlugins.js +0 -5
- package/build/runtime-esm/client/plugins/mutation.d.ts +0 -2
- package/build/runtime-esm/client/plugins/mutation.js +0 -65
- package/build/runtime-esm/client/plugins/optimisticKeys.d.ts +0 -7
- package/build/runtime-esm/client/plugins/optimisticKeys.js +0 -290
- package/build/runtime-esm/client/plugins/query.d.ts +0 -2
- package/build/runtime-esm/client/plugins/query.js +0 -69
- package/build/runtime-esm/client/plugins/subscription.d.ts +0 -20
- package/build/runtime-esm/client/plugins/subscription.js +0 -90
- package/build/runtime-esm/client/plugins/test.d.ts +0 -15
- package/build/runtime-esm/client/plugins/test.js +0 -93
- package/build/runtime-esm/client/plugins/throwOnError.d.ts +0 -8
- package/build/runtime-esm/client/plugins/throwOnError.js +0 -23
- package/build/runtime-esm/client/utils/documentPlugins.d.ts +0 -3
- package/build/runtime-esm/client/utils/documentPlugins.js +0 -33
- package/build/runtime-esm/client/utils/index.d.ts +0 -1
- package/build/runtime-esm/client/utils/index.js +0 -1
- package/build/runtime-esm/generated.d.ts +0 -5
- package/build/runtime-esm/generated.js +0 -0
- package/build/runtime-esm/imports/config.d.ts +0 -3
- package/build/runtime-esm/imports/config.js +0 -4
- package/build/runtime-esm/imports/pluginConfig.d.ts +0 -3
- package/build/runtime-esm/imports/pluginConfig.js +0 -5
- package/build/runtime-esm/index.d.ts +0 -8
- package/build/runtime-esm/index.js +0 -22
- package/build/runtime-esm/lib/config.d.ts +0 -216
- package/build/runtime-esm/lib/config.js +0 -69
- package/build/runtime-esm/lib/constants.d.ts +0 -6
- package/build/runtime-esm/lib/deepEquals.d.ts +0 -1
- package/build/runtime-esm/lib/flatten.d.ts +0 -2
- package/build/runtime-esm/lib/index.d.ts +0 -10
- package/build/runtime-esm/lib/index.js +0 -10
- package/build/runtime-esm/lib/key.d.ts +0 -6
- package/build/runtime-esm/lib/log.d.ts +0 -6
- package/build/runtime-esm/lib/lru.d.ts +0 -52
- package/build/runtime-esm/lib/pageInfo.d.ts +0 -7
- package/build/runtime-esm/lib/pagination.d.ts +0 -27
- package/build/runtime-esm/lib/scalars.d.ts +0 -14
- package/build/runtime-esm/lib/selection.d.ts +0 -2
- package/build/runtime-esm/lib/store.d.ts +0 -19
- package/build/runtime-esm/lib/types.d.ts +0 -417
- package/build/runtime-esm/public/cache.d.ts +0 -42
- package/build/runtime-esm/public/cache.js +0 -74
- package/build/runtime-esm/public/index.d.ts +0 -1
- package/build/runtime-esm/public/index.js +0 -4
- package/build/runtime-esm/public/list.d.ts +0 -18
- package/build/runtime-esm/public/list.js +0 -127
- package/build/runtime-esm/public/record.d.ts +0 -40
- package/build/runtime-esm/public/record.js +0 -70
- package/build/runtime-esm/public/tests/test.d.ts +0 -156
- package/build/runtime-esm/public/tests/test.js +0 -36
- package/build/runtime-esm/public/types.d.ts +0 -62
- package/build/runtime-esm/router/cookies.d.ts +0 -41
- package/build/runtime-esm/router/jwt.d.ts +0 -117
- package/build/runtime-esm/router/match.d.ts +0 -39
- package/build/runtime-esm/router/match.js +0 -131
- package/build/runtime-esm/router/server.d.ts +0 -24
- package/build/runtime-esm/router/server.js +0 -92
- package/build/runtime-esm/router/session.d.ts +0 -22
- package/build/runtime-esm/router/session.js +0 -74
- package/build/runtime-esm/router/types.d.ts +0 -26
- package/build/runtime-esm/router/types.js +0 -0
- package/build/runtime-esm/server/index.d.ts +0 -17
- package/build/runtime-esm/server/index.js +0 -38
- package/build/test-cjs/index.js +0 -75249
- package/build/test-cjs/package.json +0 -1
- package/build/test-esm/index.js +0 -75244
- package/build/vite/imports.d.ts +0 -40
- package/build/vite-cjs/index.js +0 -86272
- package/build/vite-cjs/package.json +0 -1
- package/build/vite-esm/index.js +0 -86264
- /package/build/{adapter-esm → adapter}/package.json +0 -0
- /package/build/{cmd-esm → cmd}/package.json +0 -0
- /package/build/{vite → lib}/ast.d.ts +0 -0
- /package/build/{codegen-esm → lib}/package.json +0 -0
- /package/build/{lib-esm → node}/package.json +0 -0
- /package/build/{runtime-esm → oauth}/package.json +0 -0
- /package/build/{runtime-cjs/router → router}/cookies.d.ts +0 -0
- /package/build/{runtime-cjs/router → router}/jwt.d.ts +0 -0
- /package/build/{test-esm → router}/package.json +0 -0
- /package/build/{runtime-esm/public → router}/types.js +0 -0
- /package/build/{runtime-esm → runtime}/cache/constants.js +0 -0
- /package/build/{runtime-esm/lib → runtime}/constants.js +0 -0
- /package/build/{runtime-cjs/lib → runtime}/deepEquals.d.ts +0 -0
- /package/build/{runtime-esm/lib → runtime}/deepEquals.js +0 -0
- /package/build/{runtime-esm/lib → runtime}/flatten.js +0 -0
- /package/build/{runtime-cjs/lib → runtime}/log.d.ts +0 -0
- /package/build/{runtime-cjs/lib → runtime}/lru.d.ts +0 -0
- /package/build/{runtime-esm/lib → runtime}/lru.js +0 -0
- /package/build/{vite-esm → runtime}/package.json +0 -0
|
@@ -0,0 +1,943 @@
|
|
|
1
|
+
import { bench, describe } from "vitest";
|
|
2
|
+
import { testConfigFile } from "../../../test/index.js";
|
|
3
|
+
import { RefetchUpdateMode } from "../../types.js";
|
|
4
|
+
import { Cache } from "../index.js";
|
|
5
|
+
const activeCategories = new Set(
|
|
6
|
+
(process.env.BENCH ?? "all").split(",").map((s) => s.trim()).filter(Boolean)
|
|
7
|
+
);
|
|
8
|
+
const skip = (...cats) => !activeCategories.has("all") && !cats.some((c) => activeCategories.has(c));
|
|
9
|
+
const MAX_N = parseInt(process.env.BENCH_MAX_N ?? "0", 10);
|
|
10
|
+
const skipN = (n) => MAX_N > 0 && n > MAX_N;
|
|
11
|
+
const QUICK = process.env.BENCH_QUICK === "1";
|
|
12
|
+
function b(name, fn, opts) {
|
|
13
|
+
if (QUICK) {
|
|
14
|
+
bench(name, fn, {
|
|
15
|
+
time: 0,
|
|
16
|
+
iterations: 3,
|
|
17
|
+
warmupTime: 0,
|
|
18
|
+
warmupIterations: 1
|
|
19
|
+
});
|
|
20
|
+
} else {
|
|
21
|
+
bench(name, fn, opts);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function bN(n, name, fn, opts) {
|
|
25
|
+
if (!skipN(n)) b(name, fn, opts);
|
|
26
|
+
}
|
|
27
|
+
const config = testConfigFile();
|
|
28
|
+
const flatSelection = {
|
|
29
|
+
fields: {
|
|
30
|
+
viewer: {
|
|
31
|
+
type: "User",
|
|
32
|
+
visible: true,
|
|
33
|
+
keyRaw: "viewer",
|
|
34
|
+
selection: {
|
|
35
|
+
fields: {
|
|
36
|
+
id: { type: "ID", visible: true, keyRaw: "id" },
|
|
37
|
+
firstName: { type: "String", visible: true, keyRaw: "firstName" },
|
|
38
|
+
lastName: { type: "String", visible: true, keyRaw: "lastName" },
|
|
39
|
+
email: { type: "String", visible: true, keyRaw: "email" },
|
|
40
|
+
age: { type: "Int", visible: true, keyRaw: "age" }
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const flatData = {
|
|
47
|
+
viewer: {
|
|
48
|
+
id: "1",
|
|
49
|
+
firstName: "Bob",
|
|
50
|
+
lastName: "Smith",
|
|
51
|
+
email: "bob@example.com",
|
|
52
|
+
age: 42
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const nestedSelection = {
|
|
56
|
+
fields: {
|
|
57
|
+
viewer: {
|
|
58
|
+
type: "User",
|
|
59
|
+
visible: true,
|
|
60
|
+
keyRaw: "viewer",
|
|
61
|
+
selection: {
|
|
62
|
+
fields: {
|
|
63
|
+
id: { type: "ID", visible: true, keyRaw: "id" },
|
|
64
|
+
firstName: { type: "String", visible: true, keyRaw: "firstName" },
|
|
65
|
+
friends: {
|
|
66
|
+
type: "User",
|
|
67
|
+
visible: true,
|
|
68
|
+
keyRaw: "friends",
|
|
69
|
+
selection: {
|
|
70
|
+
fields: {
|
|
71
|
+
id: { type: "ID", visible: true, keyRaw: "id" },
|
|
72
|
+
firstName: { type: "String", visible: true, keyRaw: "firstName" },
|
|
73
|
+
email: { type: "String", visible: true, keyRaw: "email" }
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
function makeFriends(n) {
|
|
83
|
+
return Array.from({ length: n }, (_, i) => ({
|
|
84
|
+
id: String(i + 2),
|
|
85
|
+
firstName: `Friend${i}`,
|
|
86
|
+
email: `friend${i}@example.com`
|
|
87
|
+
}));
|
|
88
|
+
}
|
|
89
|
+
function makeWideSelection(n) {
|
|
90
|
+
const fields = {
|
|
91
|
+
id: { type: "ID", visible: true, keyRaw: "id" }
|
|
92
|
+
};
|
|
93
|
+
for (let i = 0; i < n; i++) {
|
|
94
|
+
fields[`field${i}`] = { type: "String", visible: true, keyRaw: `field${i}` };
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
fields: {
|
|
98
|
+
viewer: {
|
|
99
|
+
type: "User",
|
|
100
|
+
visible: true,
|
|
101
|
+
keyRaw: "viewer",
|
|
102
|
+
selection: { fields }
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function makeWideData(n) {
|
|
108
|
+
const record = { id: "1" };
|
|
109
|
+
for (let i = 0; i < n; i++) {
|
|
110
|
+
record[`field${i}`] = `value${i}`;
|
|
111
|
+
}
|
|
112
|
+
return { viewer: record };
|
|
113
|
+
}
|
|
114
|
+
const wideSelection10 = makeWideSelection(10);
|
|
115
|
+
const wideSelection100 = makeWideSelection(100);
|
|
116
|
+
const wideSelection1000 = makeWideSelection(1e3);
|
|
117
|
+
const wideSelection10000 = makeWideSelection(1e4);
|
|
118
|
+
const wideData10 = makeWideData(10);
|
|
119
|
+
const wideData100 = makeWideData(100);
|
|
120
|
+
const wideData1000 = makeWideData(1e3);
|
|
121
|
+
const wideData10000 = makeWideData(1e4);
|
|
122
|
+
const idFirstNameSelection = {
|
|
123
|
+
fields: {
|
|
124
|
+
id: { type: "ID", visible: true, keyRaw: "id" },
|
|
125
|
+
firstName: { type: "String", visible: true, keyRaw: "firstName" }
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
const overlappingSelections100 = Array.from(
|
|
129
|
+
{ length: 100 },
|
|
130
|
+
(_, i) => ({
|
|
131
|
+
fields: {
|
|
132
|
+
id: { type: "ID", visible: true, keyRaw: "id" },
|
|
133
|
+
[`field${i}`]: { type: "String", visible: true, keyRaw: `field${i}` }
|
|
134
|
+
}
|
|
135
|
+
})
|
|
136
|
+
);
|
|
137
|
+
function makeWideListSelection(cols) {
|
|
138
|
+
const itemFields = {
|
|
139
|
+
id: { type: "ID", visible: true, keyRaw: "id" }
|
|
140
|
+
};
|
|
141
|
+
for (let i = 0; i < cols; i++) {
|
|
142
|
+
itemFields[`field${i}`] = { type: "String", visible: true, keyRaw: `field${i}` };
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
fields: {
|
|
146
|
+
viewer: {
|
|
147
|
+
type: "User",
|
|
148
|
+
visible: true,
|
|
149
|
+
keyRaw: "viewer",
|
|
150
|
+
selection: {
|
|
151
|
+
fields: {
|
|
152
|
+
id: { type: "ID", visible: true, keyRaw: "id" },
|
|
153
|
+
items: {
|
|
154
|
+
type: "Item",
|
|
155
|
+
visible: true,
|
|
156
|
+
keyRaw: "items",
|
|
157
|
+
selection: { fields: itemFields }
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
function makeWideListData(rows, cols) {
|
|
166
|
+
const items = Array.from({ length: rows }, (_, r) => {
|
|
167
|
+
const record = { id: String(r + 2) };
|
|
168
|
+
for (let c = 0; c < cols; c++) {
|
|
169
|
+
record[`field${c}`] = `r${r}c${c}`;
|
|
170
|
+
}
|
|
171
|
+
return record;
|
|
172
|
+
});
|
|
173
|
+
return { viewer: { id: "1", items } };
|
|
174
|
+
}
|
|
175
|
+
const wideList10x100Selection = makeWideListSelection(100);
|
|
176
|
+
const wideList100x10Selection = makeWideListSelection(10);
|
|
177
|
+
const wideList10x100Data = makeWideListData(10, 100);
|
|
178
|
+
const wideList100x10Data = makeWideListData(100, 10);
|
|
179
|
+
const wideList10x1000Selection = makeWideListSelection(1e3);
|
|
180
|
+
const wideList100x100Selection = makeWideListSelection(100);
|
|
181
|
+
const wideList1000x10Selection = makeWideListSelection(10);
|
|
182
|
+
const wideList10x1000Data = makeWideListData(10, 1e3);
|
|
183
|
+
const wideList100x100Data = makeWideListData(100, 100);
|
|
184
|
+
const wideList1000x10Data = makeWideListData(1e3, 10);
|
|
185
|
+
const nestedData10 = { viewer: { id: "1", firstName: "Bob", friends: makeFriends(10) } };
|
|
186
|
+
const nestedData100 = { viewer: { id: "1", firstName: "Bob", friends: makeFriends(100) } };
|
|
187
|
+
const nestedData1000 = { viewer: { id: "1", firstName: "Bob", friends: makeFriends(1e3) } };
|
|
188
|
+
const nestedData10000 = { viewer: { id: "1", firstName: "Bob", friends: makeFriends(1e4) } };
|
|
189
|
+
describe.skipIf(skip("core"))("write", () => {
|
|
190
|
+
b("flat record", () => {
|
|
191
|
+
const cache = new Cache(config);
|
|
192
|
+
cache.write({ selection: flatSelection, data: flatData });
|
|
193
|
+
});
|
|
194
|
+
b("nested list (10 items)", () => {
|
|
195
|
+
const cache = new Cache(config);
|
|
196
|
+
cache.write({ selection: nestedSelection, data: nestedData10 });
|
|
197
|
+
});
|
|
198
|
+
b("nested list (100 items)", () => {
|
|
199
|
+
const cache = new Cache(config);
|
|
200
|
+
cache.write({ selection: nestedSelection, data: nestedData100 });
|
|
201
|
+
});
|
|
202
|
+
b("nested list (1000 items)", () => {
|
|
203
|
+
const cache = new Cache(config);
|
|
204
|
+
cache.write({ selection: nestedSelection, data: nestedData1000 });
|
|
205
|
+
});
|
|
206
|
+
bN(1e4, "nested list (10000 items)", () => {
|
|
207
|
+
const cache = new Cache(config);
|
|
208
|
+
cache.write({ selection: nestedSelection, data: nestedData10000 });
|
|
209
|
+
});
|
|
210
|
+
b("wide record (10 fields)", () => {
|
|
211
|
+
const cache = new Cache(config);
|
|
212
|
+
cache.write({ selection: wideSelection10, data: wideData10 });
|
|
213
|
+
});
|
|
214
|
+
b("wide record (100 fields)", () => {
|
|
215
|
+
const cache = new Cache(config);
|
|
216
|
+
cache.write({ selection: wideSelection100, data: wideData100 });
|
|
217
|
+
});
|
|
218
|
+
b("wide record (1000 fields)", () => {
|
|
219
|
+
const cache = new Cache(config);
|
|
220
|
+
cache.write({ selection: wideSelection1000, data: wideData1000 });
|
|
221
|
+
});
|
|
222
|
+
bN(
|
|
223
|
+
1e4,
|
|
224
|
+
"wide record (10000 fields)",
|
|
225
|
+
() => {
|
|
226
|
+
const cache = new Cache(config);
|
|
227
|
+
cache.write({ selection: wideSelection10000, data: wideData10000 });
|
|
228
|
+
},
|
|
229
|
+
{ warmupIterations: 1, warmupTime: 0, iterations: 5 }
|
|
230
|
+
);
|
|
231
|
+
b("repeated writes to same record", () => {
|
|
232
|
+
const cache = new Cache(config);
|
|
233
|
+
for (let i = 0; i < 10; i++) {
|
|
234
|
+
cache.write({ selection: flatSelection, data: flatData });
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
describe.skipIf(skip("core"))("write \u2014 wide list (same total cells, different shape)", () => {
|
|
239
|
+
b("~1000 cells: 10 rows \xD7 100 cols", () => {
|
|
240
|
+
const cache = new Cache(config);
|
|
241
|
+
cache.write({ selection: wideList10x100Selection, data: wideList10x100Data });
|
|
242
|
+
});
|
|
243
|
+
b("~1000 cells: 100 rows \xD7 10 cols", () => {
|
|
244
|
+
const cache = new Cache(config);
|
|
245
|
+
cache.write({ selection: wideList100x10Selection, data: wideList100x10Data });
|
|
246
|
+
});
|
|
247
|
+
bN(1e4, "~10000 cells: 10 rows \xD7 1000 cols", () => {
|
|
248
|
+
const cache = new Cache(config);
|
|
249
|
+
cache.write({ selection: wideList10x1000Selection, data: wideList10x1000Data });
|
|
250
|
+
});
|
|
251
|
+
bN(1e4, "~10000 cells: 100 rows \xD7 100 cols", () => {
|
|
252
|
+
const cache = new Cache(config);
|
|
253
|
+
cache.write({ selection: wideList100x100Selection, data: wideList100x100Data });
|
|
254
|
+
});
|
|
255
|
+
bN(1e4, "~10000 cells: 1000 rows \xD7 10 cols", () => {
|
|
256
|
+
const cache = new Cache(config);
|
|
257
|
+
cache.write({ selection: wideList1000x10Selection, data: wideList1000x10Data });
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
describe.skipIf(skip("core"))("read", () => {
|
|
261
|
+
b("flat record", () => {
|
|
262
|
+
const cache = new Cache(config);
|
|
263
|
+
cache.write({ selection: flatSelection, data: flatData });
|
|
264
|
+
cache.read({ selection: flatSelection });
|
|
265
|
+
});
|
|
266
|
+
b("nested list (10 items)", () => {
|
|
267
|
+
const cache = new Cache(config);
|
|
268
|
+
cache.write({ selection: nestedSelection, data: nestedData10 });
|
|
269
|
+
cache.read({ selection: nestedSelection });
|
|
270
|
+
});
|
|
271
|
+
b("nested list (100 items)", () => {
|
|
272
|
+
const cache = new Cache(config);
|
|
273
|
+
cache.write({ selection: nestedSelection, data: nestedData100 });
|
|
274
|
+
cache.read({ selection: nestedSelection });
|
|
275
|
+
});
|
|
276
|
+
b("nested list (1000 items)", () => {
|
|
277
|
+
const cache = new Cache(config);
|
|
278
|
+
cache.write({ selection: nestedSelection, data: nestedData1000 });
|
|
279
|
+
cache.read({ selection: nestedSelection });
|
|
280
|
+
});
|
|
281
|
+
bN(
|
|
282
|
+
1e4,
|
|
283
|
+
"nested list (10000 items)",
|
|
284
|
+
() => {
|
|
285
|
+
const cache = new Cache(config);
|
|
286
|
+
cache.write({ selection: nestedSelection, data: nestedData10000 });
|
|
287
|
+
cache.read({ selection: nestedSelection });
|
|
288
|
+
},
|
|
289
|
+
{ warmupIterations: 1, warmupTime: 0, iterations: 5 }
|
|
290
|
+
);
|
|
291
|
+
});
|
|
292
|
+
describe.skipIf(skip("subscriptions"))("write + notify subscribers", () => {
|
|
293
|
+
b("1 subscriber, flat record", () => {
|
|
294
|
+
const cache = new Cache(config);
|
|
295
|
+
cache.write({ selection: flatSelection, data: flatData });
|
|
296
|
+
const spec = {
|
|
297
|
+
rootType: "Query",
|
|
298
|
+
selection: flatSelection,
|
|
299
|
+
onMessage: () => {
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
cache.subscribe(spec);
|
|
303
|
+
cache.write({ selection: flatSelection, data: flatData });
|
|
304
|
+
cache.unsubscribe(spec);
|
|
305
|
+
});
|
|
306
|
+
b("10 subscribers, flat record", () => {
|
|
307
|
+
const cache = new Cache(config);
|
|
308
|
+
cache.write({ selection: flatSelection, data: flatData });
|
|
309
|
+
const specs = Array.from({ length: 10 }, () => ({
|
|
310
|
+
rootType: "Query",
|
|
311
|
+
selection: flatSelection,
|
|
312
|
+
onMessage: () => {
|
|
313
|
+
}
|
|
314
|
+
}));
|
|
315
|
+
for (const s of specs) cache.subscribe(s);
|
|
316
|
+
cache.write({ selection: flatSelection, data: flatData });
|
|
317
|
+
for (const s of specs) cache.unsubscribe(s);
|
|
318
|
+
});
|
|
319
|
+
b("1 subscriber, nested list (100 items)", () => {
|
|
320
|
+
const cache = new Cache(config);
|
|
321
|
+
cache.write({ selection: nestedSelection, data: nestedData100 });
|
|
322
|
+
const spec = {
|
|
323
|
+
rootType: "Query",
|
|
324
|
+
selection: nestedSelection,
|
|
325
|
+
onMessage: () => {
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
cache.subscribe(spec);
|
|
329
|
+
cache.write({ selection: nestedSelection, data: nestedData100 });
|
|
330
|
+
cache.unsubscribe(spec);
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
function subscribedCache(selection, data) {
|
|
334
|
+
const cache = new Cache(config);
|
|
335
|
+
cache.write({ selection, data });
|
|
336
|
+
cache.subscribe({ rootType: "Query", selection, onMessage: () => {
|
|
337
|
+
} });
|
|
338
|
+
return cache;
|
|
339
|
+
}
|
|
340
|
+
describe.skipIf(skip("subscriptions"))("write \u2192 subscriber notification", () => {
|
|
341
|
+
const cacheFlat = subscribedCache(flatSelection, flatData);
|
|
342
|
+
b("flat record", () => {
|
|
343
|
+
cacheFlat.write({ selection: flatSelection, data: flatData });
|
|
344
|
+
});
|
|
345
|
+
const cacheNested10 = subscribedCache(nestedSelection, nestedData10);
|
|
346
|
+
b("nested list (10 items)", () => {
|
|
347
|
+
cacheNested10.write({ selection: nestedSelection, data: nestedData10 });
|
|
348
|
+
});
|
|
349
|
+
const cacheNested100 = subscribedCache(nestedSelection, nestedData100);
|
|
350
|
+
b("nested list (100 items)", () => {
|
|
351
|
+
cacheNested100.write({ selection: nestedSelection, data: nestedData100 });
|
|
352
|
+
});
|
|
353
|
+
const cacheNested1000 = subscribedCache(nestedSelection, nestedData1000);
|
|
354
|
+
b("nested list (1000 items)", () => {
|
|
355
|
+
cacheNested1000.write({ selection: nestedSelection, data: nestedData1000 });
|
|
356
|
+
});
|
|
357
|
+
const cacheNested10000 = skipN(1e4) ? null : subscribedCache(nestedSelection, nestedData10000);
|
|
358
|
+
bN(
|
|
359
|
+
1e4,
|
|
360
|
+
"nested list (10000 items)",
|
|
361
|
+
() => {
|
|
362
|
+
cacheNested10000.write({ selection: nestedSelection, data: nestedData10000 });
|
|
363
|
+
},
|
|
364
|
+
{ time: 0, iterations: 10, warmupTime: 0, warmupIterations: 1 }
|
|
365
|
+
);
|
|
366
|
+
const cacheWide100 = subscribedCache(wideSelection100, wideData100);
|
|
367
|
+
b("wide record (100 fields)", () => {
|
|
368
|
+
cacheWide100.write({ selection: wideSelection100, data: wideData100 });
|
|
369
|
+
});
|
|
370
|
+
const cacheWide1000 = subscribedCache(wideSelection1000, wideData1000);
|
|
371
|
+
b("wide record (1000 fields)", () => {
|
|
372
|
+
cacheWide1000.write({ selection: wideSelection1000, data: wideData1000 });
|
|
373
|
+
});
|
|
374
|
+
const cacheWide10000 = skipN(1e4) ? null : subscribedCache(wideSelection10000, wideData10000);
|
|
375
|
+
bN(
|
|
376
|
+
1e4,
|
|
377
|
+
"wide record (10000 fields)",
|
|
378
|
+
() => {
|
|
379
|
+
cacheWide10000.write({ selection: wideSelection10000, data: wideData10000 });
|
|
380
|
+
},
|
|
381
|
+
{ time: 0, iterations: 5, warmupTime: 0, warmupIterations: 1 }
|
|
382
|
+
);
|
|
383
|
+
const cacheList10x1000 = skipN(1e4) ? null : subscribedCache(wideList10x1000Selection, wideList10x1000Data);
|
|
384
|
+
bN(
|
|
385
|
+
1e4,
|
|
386
|
+
"~10000 cells: 10 rows \xD7 1000 cols",
|
|
387
|
+
() => {
|
|
388
|
+
cacheList10x1000.write({
|
|
389
|
+
selection: wideList10x1000Selection,
|
|
390
|
+
data: wideList10x1000Data
|
|
391
|
+
});
|
|
392
|
+
},
|
|
393
|
+
{ time: 0, iterations: 5, warmupTime: 0, warmupIterations: 1 }
|
|
394
|
+
);
|
|
395
|
+
const cacheList100x100 = skipN(1e4) ? null : subscribedCache(wideList100x100Selection, wideList100x100Data);
|
|
396
|
+
bN(1e4, "~10000 cells: 100 rows \xD7 100 cols", () => {
|
|
397
|
+
cacheList100x100.write({ selection: wideList100x100Selection, data: wideList100x100Data });
|
|
398
|
+
});
|
|
399
|
+
const cacheList1000x10 = skipN(1e4) ? null : subscribedCache(wideList1000x10Selection, wideList1000x10Data);
|
|
400
|
+
bN(1e4, "~10000 cells: 1000 rows \xD7 10 cols", () => {
|
|
401
|
+
cacheList1000x10.write({ selection: wideList1000x10Selection, data: wideList1000x10Data });
|
|
402
|
+
});
|
|
403
|
+
});
|
|
404
|
+
function fanOutCache(n) {
|
|
405
|
+
const cache = new Cache(config);
|
|
406
|
+
cache.write({ selection: nestedSelection, data: nestedData100 });
|
|
407
|
+
const specs = Array.from({ length: n }, () => ({
|
|
408
|
+
rootType: "Query",
|
|
409
|
+
selection: nestedSelection,
|
|
410
|
+
onMessage: () => {
|
|
411
|
+
}
|
|
412
|
+
}));
|
|
413
|
+
for (const s of specs) cache.subscribe(s);
|
|
414
|
+
return { cache, specs };
|
|
415
|
+
}
|
|
416
|
+
describe.skipIf(skip("multi-doc"))(
|
|
417
|
+
"fan-out: N documents watching same selection (100-item list)",
|
|
418
|
+
() => {
|
|
419
|
+
const f1 = fanOutCache(1);
|
|
420
|
+
b("1 document", () => {
|
|
421
|
+
f1.cache.write({ selection: nestedSelection, data: nestedData100 });
|
|
422
|
+
});
|
|
423
|
+
const f10 = fanOutCache(10);
|
|
424
|
+
b("10 documents", () => {
|
|
425
|
+
f10.cache.write({ selection: nestedSelection, data: nestedData100 });
|
|
426
|
+
});
|
|
427
|
+
const f100 = fanOutCache(100);
|
|
428
|
+
b("100 documents", () => {
|
|
429
|
+
f100.cache.write({ selection: nestedSelection, data: nestedData100 });
|
|
430
|
+
});
|
|
431
|
+
const f1000 = fanOutCache(1e3);
|
|
432
|
+
b("1000 documents", () => {
|
|
433
|
+
f1000.cache.write({ selection: nestedSelection, data: nestedData100 });
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
);
|
|
437
|
+
function sharedRecordCache(n) {
|
|
438
|
+
const cache = new Cache(config);
|
|
439
|
+
for (let i = 0; i < n; i++) {
|
|
440
|
+
const sel = {
|
|
441
|
+
fields: {
|
|
442
|
+
[`query${i}`]: {
|
|
443
|
+
type: "User",
|
|
444
|
+
visible: true,
|
|
445
|
+
keyRaw: `query${i}`,
|
|
446
|
+
selection: {
|
|
447
|
+
fields: {
|
|
448
|
+
id: { type: "ID", visible: true, keyRaw: "id" },
|
|
449
|
+
firstName: { type: "String", visible: true, keyRaw: "firstName" },
|
|
450
|
+
email: { type: "String", visible: true, keyRaw: "email" }
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
cache.write({
|
|
457
|
+
selection: sel,
|
|
458
|
+
data: { [`query${i}`]: { id: "1", firstName: "Bob", email: "bob@example.com" } }
|
|
459
|
+
});
|
|
460
|
+
cache.subscribe({ rootType: "Query", selection: sel, onMessage: () => {
|
|
461
|
+
} });
|
|
462
|
+
}
|
|
463
|
+
const updateSelection = {
|
|
464
|
+
fields: {
|
|
465
|
+
id: { type: "ID", visible: true, keyRaw: "id" },
|
|
466
|
+
firstName: { type: "String", visible: true, keyRaw: "firstName" },
|
|
467
|
+
email: { type: "String", visible: true, keyRaw: "email" }
|
|
468
|
+
}
|
|
469
|
+
};
|
|
470
|
+
return { cache, updateSelection };
|
|
471
|
+
}
|
|
472
|
+
describe.skipIf(skip("multi-doc"))("shared record: User:1 referenced from N query roots", () => {
|
|
473
|
+
const s1 = sharedRecordCache(1);
|
|
474
|
+
b("1 query root", () => {
|
|
475
|
+
s1.cache.write({
|
|
476
|
+
selection: s1.updateSelection,
|
|
477
|
+
data: { id: "1", firstName: "Alice", email: "alice@example.com" },
|
|
478
|
+
parent: "User:1"
|
|
479
|
+
});
|
|
480
|
+
});
|
|
481
|
+
const s10 = sharedRecordCache(10);
|
|
482
|
+
b("10 query roots", () => {
|
|
483
|
+
s10.cache.write({
|
|
484
|
+
selection: s10.updateSelection,
|
|
485
|
+
data: { id: "1", firstName: "Alice", email: "alice@example.com" },
|
|
486
|
+
parent: "User:1"
|
|
487
|
+
});
|
|
488
|
+
});
|
|
489
|
+
const s100 = sharedRecordCache(100);
|
|
490
|
+
b("100 query roots", () => {
|
|
491
|
+
s100.cache.write({
|
|
492
|
+
selection: s100.updateSelection,
|
|
493
|
+
data: { id: "1", firstName: "Alice", email: "alice@example.com" },
|
|
494
|
+
parent: "User:1"
|
|
495
|
+
});
|
|
496
|
+
});
|
|
497
|
+
const s1000 = sharedRecordCache(1e3);
|
|
498
|
+
b("1000 query roots", () => {
|
|
499
|
+
s1000.cache.write({
|
|
500
|
+
selection: s1000.updateSelection,
|
|
501
|
+
data: { id: "1", firstName: "Alice", email: "alice@example.com" },
|
|
502
|
+
parent: "User:1"
|
|
503
|
+
});
|
|
504
|
+
});
|
|
505
|
+
});
|
|
506
|
+
function overlapCache(n) {
|
|
507
|
+
const cache = new Cache(config);
|
|
508
|
+
for (let i = 0; i < n; i++) {
|
|
509
|
+
cache.write({
|
|
510
|
+
selection: {
|
|
511
|
+
fields: {
|
|
512
|
+
id: { type: "ID", visible: true, keyRaw: "id" },
|
|
513
|
+
[`field${i}`]: { type: "String", visible: true, keyRaw: `field${i}` }
|
|
514
|
+
}
|
|
515
|
+
},
|
|
516
|
+
data: { id: String(i + 1), [`field${i}`]: `value${i}` },
|
|
517
|
+
parent: `User:${i + 1}`
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
return cache;
|
|
521
|
+
}
|
|
522
|
+
describe.skipIf(skip("multi-doc"))("overlapping vs disjoint selections (N=100)", () => {
|
|
523
|
+
b("overlapping: N specs, same record, different fields", () => {
|
|
524
|
+
const cache = new Cache(config);
|
|
525
|
+
cache.write({ selection: wideSelection100, data: wideData100 });
|
|
526
|
+
const specs = overlappingSelections100.map((sel) => {
|
|
527
|
+
const spec = { rootType: "Query", selection: sel, onMessage: () => {
|
|
528
|
+
} };
|
|
529
|
+
cache.subscribe(spec, {});
|
|
530
|
+
return { spec };
|
|
531
|
+
});
|
|
532
|
+
cache.write({ selection: wideSelection100, data: wideData100 });
|
|
533
|
+
for (const { spec } of specs) cache.unsubscribe(spec);
|
|
534
|
+
});
|
|
535
|
+
b("disjoint: N specs, N different records, same field", () => {
|
|
536
|
+
const cache = new Cache(config);
|
|
537
|
+
const specs = Array.from({ length: 100 }, (_, i) => {
|
|
538
|
+
cache.write({
|
|
539
|
+
selection: idFirstNameSelection,
|
|
540
|
+
data: { id: String(i + 1), firstName: `User${i}` },
|
|
541
|
+
parent: `User:${i + 1}`
|
|
542
|
+
});
|
|
543
|
+
const spec = { rootType: "Query", selection: idFirstNameSelection, onMessage: () => {
|
|
544
|
+
} };
|
|
545
|
+
cache.subscribe(spec, {});
|
|
546
|
+
return { spec };
|
|
547
|
+
});
|
|
548
|
+
cache.write({
|
|
549
|
+
selection: idFirstNameSelection,
|
|
550
|
+
data: { id: "1", firstName: "Alice" },
|
|
551
|
+
parent: "User:1"
|
|
552
|
+
});
|
|
553
|
+
for (const { spec } of specs) cache.unsubscribe(spec);
|
|
554
|
+
});
|
|
555
|
+
});
|
|
556
|
+
function listPlusDetailCache(n) {
|
|
557
|
+
const cache = new Cache(config);
|
|
558
|
+
const friends = makeFriends(n);
|
|
559
|
+
cache.write({
|
|
560
|
+
selection: nestedSelection,
|
|
561
|
+
data: { viewer: { id: "1", firstName: "Bob", friends } }
|
|
562
|
+
});
|
|
563
|
+
cache.subscribe({ rootType: "Query", selection: nestedSelection, onMessage: () => {
|
|
564
|
+
} });
|
|
565
|
+
const detailFields = {
|
|
566
|
+
fields: {
|
|
567
|
+
id: { type: "ID", visible: true, keyRaw: "id" },
|
|
568
|
+
firstName: { type: "String", visible: true, keyRaw: "firstName" },
|
|
569
|
+
email: { type: "String", visible: true, keyRaw: "email" }
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
for (const friend of friends) {
|
|
573
|
+
cache.subscribe(
|
|
574
|
+
{ rootType: "Query", selection: detailFields, onMessage: () => {
|
|
575
|
+
} },
|
|
576
|
+
{ parentID: `User:${friend.id}` }
|
|
577
|
+
);
|
|
578
|
+
}
|
|
579
|
+
const updateSel = {
|
|
580
|
+
fields: {
|
|
581
|
+
id: { type: "ID", visible: true, keyRaw: "id" },
|
|
582
|
+
firstName: { type: "String", visible: true, keyRaw: "firstName" },
|
|
583
|
+
email: { type: "String", visible: true, keyRaw: "email" }
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
return { cache, updateSel };
|
|
587
|
+
}
|
|
588
|
+
describe.skipIf(skip("multi-doc"))(
|
|
589
|
+
"list query + detail queries: write one item notifies both",
|
|
590
|
+
() => {
|
|
591
|
+
const ld10 = listPlusDetailCache(10);
|
|
592
|
+
b("10-item list + 10 detail docs", () => {
|
|
593
|
+
ld10.cache.write({
|
|
594
|
+
selection: ld10.updateSel,
|
|
595
|
+
data: { id: "2", firstName: "Alice", email: "alice@example.com" },
|
|
596
|
+
parent: "User:2"
|
|
597
|
+
});
|
|
598
|
+
});
|
|
599
|
+
const ld100 = listPlusDetailCache(100);
|
|
600
|
+
b("100-item list + 100 detail docs", () => {
|
|
601
|
+
ld100.cache.write({
|
|
602
|
+
selection: ld100.updateSel,
|
|
603
|
+
data: { id: "2", firstName: "Alice", email: "alice@example.com" },
|
|
604
|
+
parent: "User:2"
|
|
605
|
+
});
|
|
606
|
+
});
|
|
607
|
+
const ld1000 = listPlusDetailCache(1e3);
|
|
608
|
+
b("1000-item list + 1000 detail docs", () => {
|
|
609
|
+
ld1000.cache.write({
|
|
610
|
+
selection: ld1000.updateSel,
|
|
611
|
+
data: { id: "2", firstName: "Alice", email: "alice@example.com" },
|
|
612
|
+
parent: "User:2"
|
|
613
|
+
});
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
);
|
|
617
|
+
describe.skipIf(skip("subscriptions"))("subscribe / unsubscribe", () => {
|
|
618
|
+
b("subscribe then unsubscribe (flat)", () => {
|
|
619
|
+
const cache = new Cache(config);
|
|
620
|
+
cache.write({ selection: flatSelection, data: flatData });
|
|
621
|
+
const spec = {
|
|
622
|
+
rootType: "Query",
|
|
623
|
+
selection: flatSelection,
|
|
624
|
+
onMessage: () => {
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
cache.subscribe(spec);
|
|
628
|
+
cache.unsubscribe(spec);
|
|
629
|
+
});
|
|
630
|
+
});
|
|
631
|
+
const appendSelection = {
|
|
632
|
+
fields: {
|
|
633
|
+
viewer: {
|
|
634
|
+
type: "User",
|
|
635
|
+
visible: true,
|
|
636
|
+
keyRaw: "viewer",
|
|
637
|
+
selection: {
|
|
638
|
+
fields: {
|
|
639
|
+
id: { type: "ID", visible: true, keyRaw: "id" },
|
|
640
|
+
friends: {
|
|
641
|
+
type: "User",
|
|
642
|
+
visible: true,
|
|
643
|
+
keyRaw: "friends",
|
|
644
|
+
updates: [RefetchUpdateMode.append],
|
|
645
|
+
selection: {
|
|
646
|
+
fields: {
|
|
647
|
+
id: { type: "ID", visible: true, keyRaw: "id" },
|
|
648
|
+
firstName: { type: "String", visible: true, keyRaw: "firstName" },
|
|
649
|
+
email: { type: "String", visible: true, keyRaw: "email" }
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
};
|
|
658
|
+
describe.skipIf(skip("lists"))("write \u2014 applyUpdates append (pagination)", () => {
|
|
659
|
+
b("append page of 10 to 100-item list", () => {
|
|
660
|
+
const cache = new Cache(config);
|
|
661
|
+
cache.write({
|
|
662
|
+
selection: appendSelection,
|
|
663
|
+
data: { viewer: { id: "1", friends: makeFriends(100) } }
|
|
664
|
+
});
|
|
665
|
+
cache.write({
|
|
666
|
+
selection: appendSelection,
|
|
667
|
+
data: { viewer: { id: "1", friends: makeFriends(10) } },
|
|
668
|
+
applyUpdates: ["append"]
|
|
669
|
+
});
|
|
670
|
+
});
|
|
671
|
+
b("append page of 100 to 1000-item list", () => {
|
|
672
|
+
const cache = new Cache(config);
|
|
673
|
+
cache.write({
|
|
674
|
+
selection: appendSelection,
|
|
675
|
+
data: { viewer: { id: "1", friends: makeFriends(1e3) } }
|
|
676
|
+
});
|
|
677
|
+
cache.write({
|
|
678
|
+
selection: appendSelection,
|
|
679
|
+
data: { viewer: { id: "1", friends: makeFriends(100) } },
|
|
680
|
+
applyUpdates: ["append"]
|
|
681
|
+
});
|
|
682
|
+
});
|
|
683
|
+
});
|
|
684
|
+
const listSelection = {
|
|
685
|
+
fields: {
|
|
686
|
+
viewer: {
|
|
687
|
+
type: "User",
|
|
688
|
+
visible: true,
|
|
689
|
+
keyRaw: "viewer",
|
|
690
|
+
selection: {
|
|
691
|
+
fields: {
|
|
692
|
+
id: { type: "ID", visible: true, keyRaw: "id" },
|
|
693
|
+
friends: {
|
|
694
|
+
type: "User",
|
|
695
|
+
visible: true,
|
|
696
|
+
keyRaw: "friends",
|
|
697
|
+
list: { name: "All_Users", connection: false, type: "User" },
|
|
698
|
+
selection: {
|
|
699
|
+
fields: {
|
|
700
|
+
id: { type: "ID", visible: true, keyRaw: "id" },
|
|
701
|
+
firstName: { type: "String", visible: true, keyRaw: "firstName" }
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
const listItemSelection = {
|
|
711
|
+
fields: {
|
|
712
|
+
id: { type: "ID", visible: true, keyRaw: "id" },
|
|
713
|
+
firstName: { type: "String", visible: true, keyRaw: "firstName" }
|
|
714
|
+
}
|
|
715
|
+
};
|
|
716
|
+
function makeListCache(n) {
|
|
717
|
+
const cache = new Cache(config);
|
|
718
|
+
cache.write({
|
|
719
|
+
selection: listSelection,
|
|
720
|
+
data: { viewer: { id: "1", friends: makeFriends(n) } }
|
|
721
|
+
});
|
|
722
|
+
cache.subscribe({ rootType: "Query", selection: listSelection, onMessage: () => {
|
|
723
|
+
} });
|
|
724
|
+
return cache;
|
|
725
|
+
}
|
|
726
|
+
describe.skipIf(skip("lists"))("list mutations", () => {
|
|
727
|
+
b("append to 10-item list", () => {
|
|
728
|
+
const cache = makeListCache(10);
|
|
729
|
+
cache.list("All_Users").append({ selection: listItemSelection, data: { id: "9999", firstName: "New" } });
|
|
730
|
+
});
|
|
731
|
+
b("append to 100-item list", () => {
|
|
732
|
+
const cache = makeListCache(100);
|
|
733
|
+
cache.list("All_Users").append({ selection: listItemSelection, data: { id: "9999", firstName: "New" } });
|
|
734
|
+
});
|
|
735
|
+
b("append to 1000-item list", () => {
|
|
736
|
+
const cache = makeListCache(1e3);
|
|
737
|
+
cache.list("All_Users").append({ selection: listItemSelection, data: { id: "9999", firstName: "New" } });
|
|
738
|
+
});
|
|
739
|
+
b("prepend to 100-item list", () => {
|
|
740
|
+
const cache = makeListCache(100);
|
|
741
|
+
cache.list("All_Users").prepend({ selection: listItemSelection, data: { id: "9999", firstName: "New" } });
|
|
742
|
+
});
|
|
743
|
+
b("remove from 10-item list", () => {
|
|
744
|
+
const cache = makeListCache(10);
|
|
745
|
+
cache.list("All_Users").remove({ id: "2" });
|
|
746
|
+
});
|
|
747
|
+
b("remove from 100-item list", () => {
|
|
748
|
+
const cache = makeListCache(100);
|
|
749
|
+
cache.list("All_Users").remove({ id: "2" });
|
|
750
|
+
});
|
|
751
|
+
b("remove from 1000-item list", () => {
|
|
752
|
+
const cache = makeListCache(1e3);
|
|
753
|
+
cache.list("All_Users").remove({ id: "2" });
|
|
754
|
+
});
|
|
755
|
+
});
|
|
756
|
+
describe.skipIf(skip("optimistic"))("optimistic write + resolve", () => {
|
|
757
|
+
b("flat record", () => {
|
|
758
|
+
const cache = new Cache(config);
|
|
759
|
+
cache.write({ selection: flatSelection, data: flatData });
|
|
760
|
+
cache.subscribe({ rootType: "Query", selection: flatSelection, onMessage: () => {
|
|
761
|
+
} });
|
|
762
|
+
const layer = cache._internal_unstable.storage.createLayer(true);
|
|
763
|
+
cache.write({
|
|
764
|
+
selection: flatSelection,
|
|
765
|
+
data: {
|
|
766
|
+
viewer: {
|
|
767
|
+
id: "1",
|
|
768
|
+
firstName: "Optimistic",
|
|
769
|
+
lastName: "Smith",
|
|
770
|
+
email: "o@example.com",
|
|
771
|
+
age: 0
|
|
772
|
+
}
|
|
773
|
+
},
|
|
774
|
+
layer: layer.id
|
|
775
|
+
});
|
|
776
|
+
cache.clearLayer(layer.id);
|
|
777
|
+
});
|
|
778
|
+
b("100-item list", () => {
|
|
779
|
+
const cache = new Cache(config);
|
|
780
|
+
cache.write({ selection: nestedSelection, data: nestedData100 });
|
|
781
|
+
cache.subscribe({ rootType: "Query", selection: nestedSelection, onMessage: () => {
|
|
782
|
+
} });
|
|
783
|
+
const layer = cache._internal_unstable.storage.createLayer(true);
|
|
784
|
+
cache.write({ selection: nestedSelection, data: nestedData100, layer: layer.id });
|
|
785
|
+
cache.clearLayer(layer.id);
|
|
786
|
+
});
|
|
787
|
+
b("1000-item list", () => {
|
|
788
|
+
const cache = new Cache(config);
|
|
789
|
+
cache.write({ selection: nestedSelection, data: nestedData1000 });
|
|
790
|
+
cache.subscribe({ rootType: "Query", selection: nestedSelection, onMessage: () => {
|
|
791
|
+
} });
|
|
792
|
+
const layer = cache._internal_unstable.storage.createLayer(true);
|
|
793
|
+
cache.write({ selection: nestedSelection, data: nestedData1000, layer: layer.id });
|
|
794
|
+
cache.clearLayer(layer.id);
|
|
795
|
+
});
|
|
796
|
+
});
|
|
797
|
+
describe.skipIf(skip("gc"))("GC tick (unsubscribed records)", () => {
|
|
798
|
+
b("100 records", () => {
|
|
799
|
+
const cache = new Cache(config);
|
|
800
|
+
for (let i = 0; i < 100; i++) {
|
|
801
|
+
cache.write({
|
|
802
|
+
selection: idFirstNameSelection,
|
|
803
|
+
data: { id: String(i), firstName: `User${i}` },
|
|
804
|
+
parent: `User:${i}`
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
cache._internal_unstable.collectGarbage();
|
|
808
|
+
});
|
|
809
|
+
b("1000 records", () => {
|
|
810
|
+
const cache = new Cache(config);
|
|
811
|
+
for (let i = 0; i < 1e3; i++) {
|
|
812
|
+
cache.write({
|
|
813
|
+
selection: idFirstNameSelection,
|
|
814
|
+
data: { id: String(i), firstName: `User${i}` },
|
|
815
|
+
parent: `User:${i}`
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
cache._internal_unstable.collectGarbage();
|
|
819
|
+
});
|
|
820
|
+
bN(1e4, "10000 records", () => {
|
|
821
|
+
const cache = new Cache(config);
|
|
822
|
+
for (let i = 0; i < 1e4; i++) {
|
|
823
|
+
cache.write({
|
|
824
|
+
selection: idFirstNameSelection,
|
|
825
|
+
data: { id: String(i), firstName: `User${i}` },
|
|
826
|
+
parent: `User:${i}`
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
cache._internal_unstable.collectGarbage();
|
|
830
|
+
});
|
|
831
|
+
});
|
|
832
|
+
function populatedCache(n) {
|
|
833
|
+
const cache = new Cache(config);
|
|
834
|
+
for (let i = 0; i < n; i++) {
|
|
835
|
+
cache.write({
|
|
836
|
+
selection: idFirstNameSelection,
|
|
837
|
+
data: { id: String(i), firstName: `User${i}` },
|
|
838
|
+
parent: `User:${i}`
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
return cache;
|
|
842
|
+
}
|
|
843
|
+
describe.skipIf(skip("gc"))("stale marking", () => {
|
|
844
|
+
const cache100 = populatedCache(100);
|
|
845
|
+
b("markAllStale (100 records)", () => {
|
|
846
|
+
cache100.markTypeStale();
|
|
847
|
+
});
|
|
848
|
+
const cache1000 = populatedCache(1e3);
|
|
849
|
+
b("markAllStale (1000 records)", () => {
|
|
850
|
+
cache1000.markTypeStale();
|
|
851
|
+
});
|
|
852
|
+
const cache10000 = skipN(1e4) ? null : populatedCache(1e4);
|
|
853
|
+
bN(1e4, "markAllStale (10000 records)", () => {
|
|
854
|
+
cache10000.markTypeStale();
|
|
855
|
+
});
|
|
856
|
+
b("markTypeStale User (100 records)", () => {
|
|
857
|
+
cache100.markTypeStale({ type: "User" });
|
|
858
|
+
});
|
|
859
|
+
b("markTypeStale User (1000 records)", () => {
|
|
860
|
+
cache1000.markTypeStale({ type: "User" });
|
|
861
|
+
});
|
|
862
|
+
});
|
|
863
|
+
describe.skipIf(skip("subscriptions"))("subscribe/unsubscribe churn", () => {
|
|
864
|
+
b("10 cycles, flat record", () => {
|
|
865
|
+
const cache = new Cache(config);
|
|
866
|
+
cache.write({ selection: flatSelection, data: flatData });
|
|
867
|
+
for (let i = 0; i < 10; i++) {
|
|
868
|
+
const spec = {
|
|
869
|
+
rootType: "Query",
|
|
870
|
+
selection: flatSelection,
|
|
871
|
+
onMessage: () => {
|
|
872
|
+
}
|
|
873
|
+
};
|
|
874
|
+
cache.subscribe(spec);
|
|
875
|
+
cache.write({ selection: flatSelection, data: flatData });
|
|
876
|
+
cache.unsubscribe(spec);
|
|
877
|
+
}
|
|
878
|
+
});
|
|
879
|
+
b("100 cycles, flat record", () => {
|
|
880
|
+
const cache = new Cache(config);
|
|
881
|
+
cache.write({ selection: flatSelection, data: flatData });
|
|
882
|
+
for (let i = 0; i < 100; i++) {
|
|
883
|
+
const spec = {
|
|
884
|
+
rootType: "Query",
|
|
885
|
+
selection: flatSelection,
|
|
886
|
+
onMessage: () => {
|
|
887
|
+
}
|
|
888
|
+
};
|
|
889
|
+
cache.subscribe(spec);
|
|
890
|
+
cache.write({ selection: flatSelection, data: flatData });
|
|
891
|
+
cache.unsubscribe(spec);
|
|
892
|
+
}
|
|
893
|
+
});
|
|
894
|
+
b("10 cycles, 100-item list", () => {
|
|
895
|
+
const cache = new Cache(config);
|
|
896
|
+
cache.write({ selection: nestedSelection, data: nestedData100 });
|
|
897
|
+
for (let i = 0; i < 10; i++) {
|
|
898
|
+
const spec = {
|
|
899
|
+
rootType: "Query",
|
|
900
|
+
selection: nestedSelection,
|
|
901
|
+
onMessage: () => {
|
|
902
|
+
}
|
|
903
|
+
};
|
|
904
|
+
cache.subscribe(spec);
|
|
905
|
+
cache.write({ selection: nestedSelection, data: nestedData100 });
|
|
906
|
+
cache.unsubscribe(spec);
|
|
907
|
+
}
|
|
908
|
+
});
|
|
909
|
+
});
|
|
910
|
+
const serialized100 = (() => {
|
|
911
|
+
const cache = new Cache(config);
|
|
912
|
+
cache.write({ selection: nestedSelection, data: nestedData100 });
|
|
913
|
+
return cache.serialize();
|
|
914
|
+
})();
|
|
915
|
+
const serialized1000 = (() => {
|
|
916
|
+
const cache = new Cache(config);
|
|
917
|
+
cache.write({ selection: nestedSelection, data: nestedData1000 });
|
|
918
|
+
return cache.serialize();
|
|
919
|
+
})();
|
|
920
|
+
const parsed100 = JSON.parse(serialized100);
|
|
921
|
+
const parsed1000 = JSON.parse(serialized1000);
|
|
922
|
+
describe.skipIf(skip("ssr"))("serialize", () => {
|
|
923
|
+
b("100-item list", () => {
|
|
924
|
+
const cache = new Cache(config);
|
|
925
|
+
cache.write({ selection: nestedSelection, data: nestedData100 });
|
|
926
|
+
cache.serialize();
|
|
927
|
+
});
|
|
928
|
+
b("1000-item list", () => {
|
|
929
|
+
const cache = new Cache(config);
|
|
930
|
+
cache.write({ selection: nestedSelection, data: nestedData1000 });
|
|
931
|
+
cache.serialize();
|
|
932
|
+
});
|
|
933
|
+
});
|
|
934
|
+
describe.skipIf(skip("ssr"))("hydrate", () => {
|
|
935
|
+
b("100-item list", () => {
|
|
936
|
+
const cache = new Cache(config);
|
|
937
|
+
cache.hydrate(parsed100);
|
|
938
|
+
});
|
|
939
|
+
b("1000-item list", () => {
|
|
940
|
+
const cache = new Cache(config);
|
|
941
|
+
cache.hydrate(parsed1000);
|
|
942
|
+
});
|
|
943
|
+
});
|